typeclass for transformation of Euclidean points

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

typeclass for transformation of Euclidean points

Christopher Howard-2
Hi. What I'd like to have for a program I am working on is a generic
typeclass for objects that can be treated like points on a 2D plane, and
a few simple transform functions (e.g., addition, rotation around an
origin) which I could combine to make more complex transformations. Of
course, it would be trivial to do this myself, but it seems like the
sort of thing somebody would have thought of already. Does anybody know
of a package providing this? (I didn't see an obvious one when searching
with hoogle.)

--
http://justonemoremathproblem.com


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: typeclass for transformation of Euclidean points

Roel van Dijk-3
You could consider the 'linear' package [1]. Any type that is an instance of the Linear.V2.R2 class could be considered to be a point on a 2D plane.

Adding and subtracting vectors can be achieved using the Linear.Vector.Additive class.
Linear.Metric.Metric has dot product and length of vectors.
The Linear.Matrix module can be used for transformations. Combining transformations is just matrix multiplication. 

I'm quite happy with the 'linear' package as a whole, but it could use more documentation showing simple operations. Its abstact nature can be a bit daunting.


2016-02-12 16:45 GMT+01:00 Christopher Howard <[hidden email]>:
Hi. What I'd like to have for a program I am working on is a generic typeclass for objects that can be treated like points on a 2D plane, and a few simple transform functions (e.g., addition, rotation around an origin) which I could combine to make more complex transformations. Of course, it would be trivial to do this myself, but it seems like the sort of thing somebody would have thought of already. Does anybody know of a package providing this? (I didn't see an obvious one when searching with hoogle.)


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe