SG-1.0: Small geometry library for dealing with vectors and collision detection

Data.SG.Vector.Basic

Description

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

Synopsis

Documentation

newtype Pair a Source

A pair, which acts as a 2D vector.

Constructors

Pair (a, a) 

newtype Quad a Source

A quad, which acts as a 4D vector.

Constructors

Quad (a, a, a, a) 

Instances

newtype LinePair a Source

A pair of (position vector, direction vector) to be used as a 2D line.

Constructors

LinePair (Pair a, Pair a) 

Instances

Geometry Pair Pair LinePair 
Eq a => Eq (LinePair a) 
Ord a => Ord (LinePair a) 
Read a => Read (LinePair a) 
Show a => Show (LinePair a) 

newtype LineTriple a Source

A pair of (position vector, direction vector) to be used as a 3D line.

Constructors

LineTriple (Triple a, Triple a) 

Instances