graphics-drawingcombinators-1.0.2: A functional interface to 2D drawing in OpenGL



An affine transformation is a linear transformation followed by a translation; i.e. it is a function

 \x -> A*x + b

Where A is a linear transformation. Affine transformations are the set of image transformations supported by Graphics.DrawingCombinators, roughly translate, rotate, scale, and compositions thereof.



type R2 = (R, R)Source

data Affine Source

An Affine transformation from R2 to R2.

 [Affine] = R2 -> R2

The Monoid instance (identity, compose)


compose :: Affine -> Affine -> AffineSource

 [[compose a b]] = [[a]] . [[b]]

apply :: Affine -> R2 -> R2Source

 [[apply a]] = [[a]]

identity :: AffineSource

 [[identity]] = id

translate :: R2 -> AffineSource

 [[translate t]] x = [[t]] x + t

rotate :: R -> AffineSource

 [[rotate r]] (x,y) = (cos(r)x - sin(r)y, sin(r)x + cos(r)y)

scale :: R -> R -> AffineSource

 [[scale xs ys]] (x,y) = (xs*x, ys*y)