From Math Images
A transformation matrix is a special matrix that can describe transformations.
Transformation matrices can represent two dimensional transformations as well as three dimensional transformations. Each type of transformation is represented by certain elements in the matrix.
Examples in 2D Graphics
In 2D graphics Linear transformations can be represented by 2x2 matrices. Most common transformations such as rotation, scaling, shearing, and reflection are linear transformations and can be represented in the 2x2 matrix. Other affine transformations can be represented in a 3x3 matrix.
For rotation by an angle θ clockwise about the origin, the functional form is x' = xcosθ + ysinθ and y' = − xsinθ + ycosθ. Written in matrix form, this becomes:
Similarly, for a rotation counterclockwise about the origin, the functional form is and and the matrix form is:
For scaling we have and . The matrix form is:
For shear mapping (visually similar to slanting), there are two possibilities. For a shear parallel to the x axis has and ; the shear matrix, applied to column vectors, is:
A shear parallel to the y axis has and , which has matrix form:
2D Affine Transformations
Often In computer graphics affine transformation matrices are used to perform translations. Using an affine transformation matrix allows each matrix to be multiplied and combined into 1 matrix. To represent an affine translation matrix you must represent your original point as (x,y,1) instead of (x,y).