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:
<blockquote> <pre> T = | m00 m01 m02 | | m10 m11 m12 | | 0 0 1 | </pre> </blockquote> 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: <blockquote> <pre> | x' | = T x | x | | y' | | y | | 1 | | 1 | </pre> </blockquote>
=== Transformation Composition ===
Affine transformations can be composed using the {link #compose} method. Composition is computed via multiplication of the transformation matrices, and is defined as:
<blockquote> <pre> A.compose(B) = T<sub>B</sub> x T<sub>A</sub> </pre> </blockquote> This produces a transformation whose effect is that of A followed by B. 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.
The composition of transformations is in general <i>not</i> commutative.
=== Transformation Inversion ===
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} method computes the inverse of a transformation, if one exists.
- Companion
- class
Value members
Concrete methods
Creates a transformation for a reflection about the line (x0,y0) - (x1,y1).
Creates a transformation for a reflection about the line (x0,y0) - (x1,y1).
- Value Params
- x0
the x-ordinate of a point on the reflection line
- x1
the x-ordinate of a another point on the reflection line
- y0
the y-ordinate of a point on the reflection line
- y1
the y-ordinate of a another point on the reflection line return a transformation for the reflection
Creates a transformation for a reflection about the line (0,0) - (x,y).
Creates a transformation for a reflection about the line (0,0) - (x,y).
- Value Params
- x
the x-ordinate of a point on the reflection line
- y
the y-ordinate of a point on the reflection line return a transformation for the reflection
Creates a transformation for a rotation about the origin by an angle <i>theta</i>. Positive angles correspond to a rotation in the counter-clockwise direction.
Creates a transformation for a rotation about the origin by an angle <i>theta</i>. Positive angles correspond to a rotation in the counter-clockwise direction.
- Value Params
- theta
the rotation angle, in radians return a transformation for the rotation
Creates a transformation for a rotation by an angle <i>theta</i>, specified by the sine and cosine of the angle. This allows providing exact values for sin(theta) and cos(theta) for the common case of rotations of multiples of quarter-circles.
Creates a transformation for a rotation by an angle <i>theta</i>, specified by the sine and cosine of the angle. This allows providing exact values for sin(theta) and cos(theta) for the common case of rotations of multiples of quarter-circles.
- Value Params
- cosTheta
the cosine of the rotation angle return a transformation for the rotation
- sinTheta
the sine of the rotation angle
Creates a transformation for a rotation about the point (x,y) by an angle <i>theta</i>. Positive angles correspond to a rotation in the counter-clockwise direction.
Creates a transformation for a rotation about the point (x,y) by an angle <i>theta</i>. Positive angles correspond to a rotation in the counter-clockwise direction.
- Value Params
- theta
the rotation angle, in radians
- x
the x-ordinate of the rotation point
- y
the y-ordinate of the rotation point return a transformation for the rotation
Creates a transformation for a rotation about the point (x,y) by an angle <i>theta</i>, specified by the sine and cosine of the angle. This allows providing exact values for sin(theta) and cos(theta) for the common case of rotations of multiples of quarter-circles.
Creates a transformation for a rotation about the point (x,y) by an angle <i>theta</i>, specified by the sine and cosine of the angle. This allows providing exact values for sin(theta) and cos(theta) for the common case of rotations of multiples of quarter-circles.
- Value Params
- cosTheta
the cosine of the rotation angle
- sinTheta
the sine of the rotation angle
- x
the x-ordinate of the rotation point
- y
the y-ordinate of the rotation point return a transformation for the rotation
Creates a transformation for a scaling relative to the origin.
Creates a transformation for a scaling relative to the origin.
- Value Params
- xScale
the value to scale by in the x direction
- yScale
the value to scale by in the y direction return a transformation for the scaling
Creates a transformation for a scaling relative to the point (x,y).
Creates a transformation for a scaling relative to the point (x,y).
- Value Params
- x
the x-ordinate of the point to scale around
- xScale
the value to scale by in the x direction
- y
the y-ordinate of the point to scale around return a transformation for the scaling
- yScale
the value to scale by in the y direction
Creates a transformation for a shear.
Creates a transformation for a shear.
- Value Params
- xShear
the value to shear by in the x direction
- yShear
the value to shear by in the y direction return a transformation for the shear