Represents an affine transformation on the 2D Cartesian plane. It can be used to transform a {@link Coordinate} or {@link Geometry}. An affine transformation is a mapping of the 2D plane into itself via a series of transformations of the following basic types:
- reflection (through a line)
- rotation (around the origin)
- scaling (relative to the origin)
- shearing (in both the X and Y directions)
- translation
In general, affine transformations preserve straightness and parallel lines, but do not preserve distance or shape.
An affine transformation can be represented by a 3x3 matrix in the following form:
T = | m00 m01 m02 | | m10 m11 m12 | | 0 0 1 |
A coordinate P = (x, y) can be transformed to a new coordinate P' = (x', y') by representing it as a 3x1 matrix and using matrix multiplication to compute:
| x' | = T x | x | | y' | | y | | 1 | | 1 |
Affine transformations can be composed using the {@link #compose} method.The composition of transformations is in general not commutative. transformation matrices as follows:
A.compose(B) = TB x TA
This produces a transformation whose effect is that of A followed by B. Composition is computed via multiplication of the The methods {@link #reflect}, {@link #rotate}, {@link #scale}, {@link #shear}, and {@link #translate} have the effect of composing a transformation of that type with the transformation they are invoked on.
Affine transformations may be invertible or non-invertible. If a transformation is invertible, then there exists an inverse transformation which when composed produces the identity transformation. The {@link #getInverse} methodcomputes the inverse of a transformation, if one exists.
@author Martin Davis