Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Some types that are very basic vectors. Most of the use that can be made of the vectors is in their type-class instances, which support a powerful set of operations. For example:
fmap (*3) v -- Scales vector v by 3 pure 0 -- Creates a vector filled with zeroes v + w -- Adds two vectors (there is a 'Num' instance, basically)
Plus all the instances for the classes in Data.SG.Vector, which allows you
to use getX
and so on.
You will probably want to create more friendly type synonyms, such as:
type Vector2 = Pair Double type Vector3 = Triple Double type Line2 = LinePair Double type Line3 = LineTriple Double
Documentation
A pair, which acts as a 2D vector.
Pair (a, a) |
Functor Pair Source # | |
Applicative Pair Source # | |
Foldable Pair Source # | |
Traversable Pair Source # | |
VectorNum Pair Source # | |
Coord2 Pair Source # | |
Coord Pair Source # | |
IsomorphicVectors Pair Rel2' Source # | |
IsomorphicVectors Pair Point2' Source # | |
IsomorphicVectors Rel2' Pair Source # | |
IsomorphicVectors Point2' Pair Source # | |
Geometry Pair Pair LinePair Source # | |
Eq a => Eq (Pair a) Source # | |
(Show a, Eq a, Num a) => Num (Pair a) Source # | |
Ord a => Ord (Pair a) Source # | |
Read a => Read (Pair a) Source # | |
Show a => Show (Pair a) Source # | |
A triple, which acts as a 3D vector.
Triple (a, a, a) |
Functor Triple Source # | |
Applicative Triple Source # | |
Foldable Triple Source # | |
Traversable Triple Source # | |
VectorNum Triple Source # | |
Coord3 Triple Source # | |
Coord2 Triple Source # | |
Coord Triple Source # | |
IsomorphicVectors Triple Rel3' Source # | |
IsomorphicVectors Triple Point3' Source # | |
IsomorphicVectors Rel3' Triple Source # | |
IsomorphicVectors Point3' Triple Source # | |
Geometry Triple Triple LineTriple Source # | |
Eq a => Eq (Triple a) Source # | |
(Show a, Eq a, Num a) => Num (Triple a) Source # | |
Ord a => Ord (Triple a) Source # | |
Read a => Read (Triple a) Source # | |
Show a => Show (Triple a) Source # | |
A quad, which acts as a 4D vector.
Quad (a, a, a, a) |
Functor Quad Source # | |
Applicative Quad Source # | |
Foldable Quad Source # | |
Traversable Quad Source # | |
VectorNum Quad Source # | |
Coord3 Quad Source # | |
Coord2 Quad Source # | |
Coord Quad Source # | |
Eq a => Eq (Quad a) Source # | |
(Show a, Eq a, Num a) => Num (Quad a) Source # | |
Ord a => Ord (Quad a) Source # | |
Read a => Read (Quad a) Source # | |
Show a => Show (Quad a) Source # | |
A pair of (position vector, direction vector) to be used as a 2D line.
newtype LineTriple a Source #
A pair of (position vector, direction vector) to be used as a 3D line.
LineTriple (Triple a, Triple a) |