SGplus-1.1: (updated) Small geometry library for dealing with vectors and collision detection

Data.SG

Description

A small geometry library, with vectors, matrices and simple shape collision detection that is intended to be straightforward in two and three dimensions.

The basics of vectors are in the Data.SG.Vector module, the basics of lines and geometry tests (e.g. testing whether a point is on a line) are in Data.SG.Geometry, with further specialised tests in Data.SG.Geometry.TwoDim and Data.SG.Geometry.ThreeDim. Matrix transformations are in Data.SG.Matrix and shapes (with collision detection) are in Data.SG.Shape.

The names for most of the types in this library end with a prime. This is because it is intended that you specialise these types (usually to Float or Double) in your application as follows:

type Point2 = Point2' Double
type Rel2 = Rel2' Double
type Line2 = Line2' Double
type Matrix22 = Matrix22' Double

Much of the use of the types (especially vectors) in this library is made using type-classes such as Num, Functor, Applicative and so on. For more explanation on some of the less well-known type-classes, see either the article Typeclassopedia in The Monad Reader (http://www.haskell.org/haskellwiki/The_Monad.Reader) issue 13 (http://www.haskell.org/sitewiki/images/8/85/TMR-Issue13.pdf), or my own notes at http://www.twistedsquare.com/haskell.html.

To understand what various functions will actually do, look at the SGdemo project (http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SGdemo) on Hackage (and its code) which provides a visual demonstration of several of the functions.