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)

Instances

 Functor Pair Applicative Pair Foldable Pair Traversable Pair VectorNum Pair Coord2 Pair Coord Pair IsomorphicVectors Pair Rel2' IsomorphicVectors Pair Point2' IsomorphicVectors Rel2' Pair IsomorphicVectors Point2' Pair Geometry Pair Pair LinePair Eq a => Eq (Pair a) (Show a, Eq a, Num a) => Num (Pair a) Ord a => Ord (Pair a) Read a => Read (Pair a) Show a => Show (Pair a)

newtype Triple a Source

A triple, which acts as a 3D vector.

Constructors

 Triple (a, a, a)

Instances

 Functor Triple Applicative Triple Foldable Triple Traversable Triple VectorNum Triple Coord3 Triple Coord2 Triple Coord Triple IsomorphicVectors Triple Rel3' IsomorphicVectors Triple Point3' IsomorphicVectors Rel3' Triple IsomorphicVectors Point3' Triple Geometry Triple Triple LineTriple Eq a => Eq (Triple a) (Show a, Eq a, Num a) => Num (Triple a) Ord a => Ord (Triple a) Read a => Read (Triple a) Show a => Show (Triple 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

 Geometry Triple Triple LineTriple Eq a => Eq (LineTriple a) Ord a => Ord (LineTriple a) Read a => Read (LineTriple a) Show a => Show (LineTriple a)