An affine transformation is a function between two different coordinate systems (or affine spaces) which preserves certain properties. These properties include:
- Points (points that exists in the first coordinate system will exist in the second coordinate system)
- Straight lines (lines that are straight in the first coordinate system are straight in the second)
- Parallelism (lines that are parallel in the first coordinate system are parallel in the second)
An affine transformation can encompass the following “basic” modifications:
The Transformation Matrix
A 2D affine transformation matrix is always in the form:
This maps from one affine space to another via the equation:
Note how one more matrix dimension is used than the dimension of the space you wish to apply the affine transformation to. This is so that translation transformations can be performed.
A 2D translation can be described by the following equation (using homogeneous coordinates):
A 2D scaling can be done with:
A 2D counter-clockwise rotation can be described by the following equation:
Note that the above equation performs rotation around the origin. To perform rotation around an arbitrary point, first translate the point to the origin, perform the rotation, and then translate back.
3D rotation can be divided into 3 rotations around each of the axis:
A x direction shear (a shearing along x that is proportional to y):
A y direction shear (a shearing along y that is proportional to x):
Multiple affine transformations (translation, rotation, shear, e.t.c) can be combined into a single transformation matrix.
Remember, we can do this because matrix multiplication is associative!
\(A(Bx) = (AB)x\).