An affine transformation matrix performs a linear mapping from 2D coordinates to other 2D coordinates that preserves the “straightness” and “parallelness” of lines.
Such a coordinate transformation can be represented by a 3 row by 3 column matrix with an implied last row of [ 0 0 1 ]
. This matrix transforms source coordinates (x, y)
into destination coordinates (x',y')
by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:
[ x ] [ a c tx ] [ x ] [ a * x + c * y + tx ]
[ y ] = [ b d ty ] [ y ] = [ b * x + d * y + ty ]
[ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
Note the locations of b and c.
This class is optimized for speed and minimizes calculations based on its knowledge of the underlying matrix (as opposed to say simply performing matrix multiplication).
Matrix()
Matrix(a, b, c, d, tx, ty)
Matrix(values)
Matrix(matrix)
a
b
c
d
tx
ty
values
translation