@@ -3,6 +3,10 @@ module Transform2D where
33It is used primarily with the `groupTransform` function from `Graphics.Collage` and
44allows you to do things like rotation, scaling, translation, shearing, and reflection.
55
6+Note that all the matrices in this library are 3x3 matrices of homogeneous
7+coordinates, used for affine transformations. Since the third row as always 0 0
8+1, we omit this below.
9+
610# Basic Transforms
711@docs identity, matrix, rotation
812
@@ -18,8 +22,8 @@ data Transform2D = Transform2D
1822not change anything, but it can come in handy as a default or
1923base case.
2024
21− / 1 0 \
22− \ 0 1 /
25+ / 1 0 0 \
26+ \ 0 1 0 /
2327-}
2428identity : Transform2D
2529identity = Native.Transform2D.identity
@@ -29,10 +33,10 @@ such as scales, shears, reflections, and translations.
2933
3034 matrix a b c d dx dy
3135
32− / a b \
33− \ c d /
36+ / a b dx \
37+ \ c d dy /
3438
35−And `dx` and `dy` are the translation values.
39+Note that `dx` and `dy` are the translation values.
3640-}
3741matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
3842matrix = Native.Transform2D.matrix
@@ -40,8 +44,8 @@ matrix = Native.Transform2D.matrix
4044{-| Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
4145Given an angle t, it creates a counterclockwise rotation matrix:
4246
43− / cos t -sin t \
44− \ sin t cos t /
47+ / cos t -sin t 0 \
48+ \ sin t cos t 0 /
4549-}
4650rotation : Float -> Transform2D
4751rotation = Native.Transform2D.rotation
@@ -61,8 +65,8 @@ translation x y = matrix 1 0 0 1 x y
6165
6266 scale a
6367
64− / a 0 \
65− \ 0 a /
68+ / a 0 0 \
69+ \ 0 a 0 /
6670-}
6771scale : Float -> Transform2D
6872scale a = matrix a 0 0 a 0 0