object AffineTransformation
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:
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:T = | m00 m01 m02 | | m10 m11 m12 | | 0 0 1 |
| x' | = T x | x | | y' | | y | | 1 | | 1 |
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:
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.A.compose(B) = TB x TA
The composition of transformations is in general not 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.
- Alphabetic
- By Inheritance
- AffineTransformation
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def reflectionInstance(x: Double, y: Double): AffineTransformation
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).
- 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
- def reflectionInstance(x0: Double, y0: Double, x1: Double, y1: Double): AffineTransformation
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).
- x0
the x-ordinate of a point on the reflection line
- y0
the y-ordinate of a point on the reflection line
- x1
the x-ordinate of a another point on the reflection line
- y1
the y-ordinate of a another point on the reflection line return a transformation for the reflection
- def rotationInstance(sinTheta: Double, cosTheta: Double, x: Double, y: Double): AffineTransformation
Creates a transformation for a rotation about the point (x,y) by an angle theta, specified by the sine and cosine of the angle.
Creates a transformation for a rotation about the point (x,y) by an angle theta, 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.
- sinTheta
the sine of the rotation angle
- cosTheta
the cosine 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
- def rotationInstance(theta: Double, x: Double, y: Double): AffineTransformation
Creates a transformation for a rotation about the point (x,y) by an angle theta.
Creates a transformation for a rotation about the point (x,y) by an angle theta. Positive angles correspond to a rotation in the counter-clockwise direction.
- 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
- def rotationInstance(sinTheta: Double, cosTheta: Double): AffineTransformation
Creates a transformation for a rotation by an angle theta, specified by the sine and cosine of the angle.
Creates a transformation for a rotation by an angle theta, 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.
- sinTheta
the sine of the rotation angle
- cosTheta
the cosine of the rotation angle return a transformation for the rotation
- def rotationInstance(theta: Double): AffineTransformation
Creates a transformation for a rotation about the origin by an angle theta.
Creates a transformation for a rotation about the origin by an angle theta. Positive angles correspond to a rotation in the counter-clockwise direction.
- theta
the rotation angle, in radians return a transformation for the rotation
- def scaleInstance(xScale: Double, yScale: Double, x: Double, y: Double): AffineTransformation
Creates a transformation for a scaling relative to the point (x,y).
Creates a transformation for a scaling relative to the point (x,y).
- xScale
the value to scale by in the x direction
- yScale
the value to scale by in the y direction
- x
the x-ordinate of the point to scale around
- y
the y-ordinate of the point to scale around return a transformation for the scaling
- def scaleInstance(xScale: Double, yScale: Double): AffineTransformation
Creates a transformation for a scaling relative to the origin.
Creates a transformation for a scaling relative to the origin.
- 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
- def shearInstance(xShear: Double, yShear: Double): AffineTransformation
Creates a transformation for a shear.
Creates a transformation for a shear.
- 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
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def translationInstance(x: Double, y: Double): AffineTransformation
Creates a transformation for a translation.
Creates a transformation for a translation.
- x
the value to translate by in the x direction
- y
the value to translate by in the y direction return a transformation for the translation
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()