on c19ccfe help sign in
elk/libraries/Matrix2D.elm
36 lines 926 B history raw
2module Matrix2D where
4import Native.Matrix2D as M
6-- Create an identity matrix.
7--
8-- / 1 0 \\
9-- \\ 0 1 /
10identity : Matrix2D
12-- Creates an arbitrary matrix. This lets you create scales, shears, reflections,
13-- translations, or any other 2D transform.
14--
15-- matrix a b c d dx dy
16--
17-- / a b \\
18-- \\ c d /
19--
20-- And `dx` and `dy` are the translation values.
21matrix : Float -> Float -> Float -> Float -> Float -> Float -> Matrix2D
23-- Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
24-- Given an angle t, it creates a counterclockwise rotation matrix:
25--
26-- / cos t -sin t \\
27-- \\ sin t cos t /
28rotation : Float -> Matrix2D
30-- Multiplies two matrices together:
31--
32-- multiply a b
33--
34-- / a11 a12 \\ . / b11 b12 \\
35-- \\ a21 a22 / \\ b21 b22 /
36multiply : Matrix2D -> Matrix2D -> Matrix2D