Represents a 2D affine-transformation matrix. More...
Public Member Functions | |
| AffineTransform () noexcept | |
| Creates an identity transform. | |
| AffineTransform (const AffineTransform &other) noexcept | |
| Creates a copy of another transform. | |
| AffineTransform (float mat00, float mat01, float mat02, float mat10, float mat11, float mat12) noexcept | |
| Creates a transform from a set of raw matrix values. | |
| AffineTransform & | operator= (const AffineTransform &other) noexcept |
| Copies from another AffineTransform object. | |
| bool | operator== (const AffineTransform &other) const noexcept |
| Compares two transforms. | |
| bool | operator!= (const AffineTransform &other) const noexcept |
| Compares two transforms. | |
| template<typename ValueType > | |
| void | transformPoint (ValueType &x, ValueType &y) const noexcept |
| Transforms a 2D co-ordinate using this matrix. | |
| template<typename ValueType > | |
| void | transformPoints (ValueType &x1, ValueType &y1, ValueType &x2, ValueType &y2) const noexcept |
| Transforms two 2D co-ordinates using this matrix. | |
| template<typename ValueType > | |
| void | transformPoints (ValueType &x1, ValueType &y1, ValueType &x2, ValueType &y2, ValueType &x3, ValueType &y3) const noexcept |
| Transforms three 2D co-ordinates using this matrix. | |
| AffineTransform | translated (float deltaX, float deltaY) const noexcept |
| Returns a new transform which is the same as this one followed by a translation. | |
| AffineTransform | rotated (float angleInRadians) const noexcept |
| Returns a transform which is the same as this one followed by a rotation. | |
| AffineTransform | rotated (float angleInRadians, float pivotX, float pivotY) const noexcept |
| Returns a transform which is the same as this one followed by a rotation about a given point. | |
| AffineTransform | scaled (float factorX, float factorY) const noexcept |
| Returns a transform which is the same as this one followed by a re-scaling. | |
| AffineTransform | scaled (float factorX, float factorY, float pivotX, float pivotY) const noexcept |
| Returns a transform which is the same as this one followed by a re-scaling. | |
| AffineTransform | sheared (float shearX, float shearY) const noexcept |
| Returns a transform which is the same as this one followed by a shear. | |
| AffineTransform | inverted () const noexcept |
| Returns a matrix which is the inverse operation of this one. | |
| AffineTransform | followedBy (const AffineTransform &other) const noexcept |
| Returns the result of concatenating another transformation after this one. | |
| bool | isIdentity () const noexcept |
| Returns true if this transform has no effect on points. | |
| bool | isSingularity () const noexcept |
| Returns true if this transform maps to a singularity - i.e. | |
| bool | isOnlyTranslation () const noexcept |
| Returns true if the transform only translates, and doesn't scale or rotate the points. | |
| float | getTranslationX () const noexcept |
| If this transform is only a translation, this returns the X offset. | |
| float | getTranslationY () const noexcept |
| If this transform is only a translation, this returns the X offset. | |
| float | getScaleFactor () const noexcept |
| Returns the approximate scale factor by which lengths will be transformed. | |
Static Public Member Functions | |
| static AffineTransform | translation (float deltaX, float deltaY) noexcept |
| Returns a new transform which is a translation. | |
| static AffineTransform | rotation (float angleInRadians) noexcept |
| Returns a new transform which is a rotation about (0, 0). | |
| static AffineTransform | rotation (float angleInRadians, float pivotX, float pivotY) noexcept |
| Returns a new transform which is a rotation about a given point. | |
| static AffineTransform | scale (float factorX, float factorY) noexcept |
| Returns a new transform which is a re-scale about the origin. | |
| static AffineTransform | scale (float factorX, float factorY, float pivotX, float pivotY) noexcept |
| Returns a new transform which is a re-scale centred around the point provided. | |
| static AffineTransform | shear (float shearX, float shearY) noexcept |
| Returns a shear transform, centred around the origin (0, 0). | |
| static AffineTransform | fromTargetPoints (float x00, float y00, float x10, float y10, float x01, float y01) noexcept |
| Returns the transform that will map three known points onto three coordinates that are supplied. | |
| static AffineTransform | fromTargetPoints (float sourceX1, float sourceY1, float targetX1, float targetY1, float sourceX2, float sourceY2, float targetX2, float targetY2, float sourceX3, float sourceY3, float targetX3, float targetY3) noexcept |
| Returns the transform that will map three specified points onto three target points. | |
Public Attributes | |
| float | mat00 |
| float | mat01 |
| float | mat02 |
| float | mat10 |
| float | mat11 |
| float | mat12 |
Static Public Attributes | |
| static const AffineTransform | identity |
| A ready-to-use identity transform, which you can use to append other transformations to. | |
Represents a 2D affine-transformation matrix.
An affine transformation is a transformation such as a rotation, scale, shear, resize or translation.
These are used for various 2D transformation tasks, e.g. with Path objects.
| AffineTransform::AffineTransform | ( | ) |
Creates an identity transform.
| AffineTransform::AffineTransform | ( | const AffineTransform & | other ) |
Creates a copy of another transform.
| AffineTransform::AffineTransform | ( | float | mat00, |
| float | mat01, | ||
| float | mat02, | ||
| float | mat10, | ||
| float | mat11, | ||
| float | mat12 | ||
| ) |
Creates a transform from a set of raw matrix values.
The resulting matrix is:
(mat00 mat01 mat02) (mat10 mat11 mat12) ( 0 0 1 )
| AffineTransform& AffineTransform::operator= | ( | const AffineTransform & | other ) |
Copies from another AffineTransform object.
| bool AffineTransform::operator== | ( | const AffineTransform & | other ) | const |
Compares two transforms.
| bool AffineTransform::operator!= | ( | const AffineTransform & | other ) | const |
Compares two transforms.
| void AffineTransform::transformPoint | ( | ValueType & | x, |
| ValueType & | y | ||
| ) | const |
Transforms a 2D co-ordinate using this matrix.
| void AffineTransform::transformPoints | ( | ValueType & | x1, |
| ValueType & | y1, | ||
| ValueType & | x2, | ||
| ValueType & | y2 | ||
| ) | const |
Transforms two 2D co-ordinates using this matrix.
This is just a shortcut for calling transformPoint() on each of these pairs of coordinates in turn. (And putting all the calculations into one function hopefully also gives the compiler a bit more scope for pipelining it).
| void AffineTransform::transformPoints | ( | ValueType & | x1, |
| ValueType & | y1, | ||
| ValueType & | x2, | ||
| ValueType & | y2, | ||
| ValueType & | x3, | ||
| ValueType & | y3 | ||
| ) | const |
Transforms three 2D co-ordinates using this matrix.
This is just a shortcut for calling transformPoint() on each of these pairs of coordinates in turn. (And putting all the calculations into one function hopefully also gives the compiler a bit more scope for pipelining it).
| AffineTransform AffineTransform::translated | ( | float | deltaX, |
| float | deltaY | ||
| ) | const |
Returns a new transform which is the same as this one followed by a translation.
| static AffineTransform AffineTransform::translation | ( | float | deltaX, |
| float | deltaY | ||
| ) | [static] |
Returns a new transform which is a translation.
| AffineTransform AffineTransform::rotated | ( | float | angleInRadians ) | const |
Returns a transform which is the same as this one followed by a rotation.
The rotation is specified by a number of radians to rotate clockwise, centred around the origin (0, 0).
| AffineTransform AffineTransform::rotated | ( | float | angleInRadians, |
| float | pivotX, | ||
| float | pivotY | ||
| ) | const |
Returns a transform which is the same as this one followed by a rotation about a given point.
The rotation is specified by a number of radians to rotate clockwise, centred around the co-ordinates passed in.
| static AffineTransform AffineTransform::rotation | ( | float | angleInRadians ) | [static] |
Returns a new transform which is a rotation about (0, 0).
| static AffineTransform AffineTransform::rotation | ( | float | angleInRadians, |
| float | pivotX, | ||
| float | pivotY | ||
| ) | [static] |
Returns a new transform which is a rotation about a given point.
| AffineTransform AffineTransform::scaled | ( | float | factorX, |
| float | factorY | ||
| ) | const |
Returns a transform which is the same as this one followed by a re-scaling.
The scaling is centred around the origin (0, 0).
| AffineTransform AffineTransform::scaled | ( | float | factorX, |
| float | factorY, | ||
| float | pivotX, | ||
| float | pivotY | ||
| ) | const |
Returns a transform which is the same as this one followed by a re-scaling.
The scaling is centred around the origin provided.
| static AffineTransform AffineTransform::scale | ( | float | factorX, |
| float | factorY | ||
| ) | [static] |
Returns a new transform which is a re-scale about the origin.
| static AffineTransform AffineTransform::scale | ( | float | factorX, |
| float | factorY, | ||
| float | pivotX, | ||
| float | pivotY | ||
| ) | [static] |
Returns a new transform which is a re-scale centred around the point provided.
| AffineTransform AffineTransform::sheared | ( | float | shearX, |
| float | shearY | ||
| ) | const |
Returns a transform which is the same as this one followed by a shear.
The shear is centred around the origin (0, 0).
| static AffineTransform AffineTransform::shear | ( | float | shearX, |
| float | shearY | ||
| ) | [static] |
Returns a shear transform, centred around the origin (0, 0).
| AffineTransform AffineTransform::inverted | ( | ) | const |
Returns a matrix which is the inverse operation of this one.
Some matrices don't have an inverse - in this case, the method will just return an identity transform.
| static AffineTransform AffineTransform::fromTargetPoints | ( | float | x00, |
| float | y00, | ||
| float | x10, | ||
| float | y10, | ||
| float | x01, | ||
| float | y01 | ||
| ) | [static] |
Returns the transform that will map three known points onto three coordinates that are supplied.
This returns the transform that will transform (0, 0) into (x00, y00), (1, 0) to (x10, y10), and (0, 1) to (x01, y01).
| static AffineTransform AffineTransform::fromTargetPoints | ( | float | sourceX1, |
| float | sourceY1, | ||
| float | targetX1, | ||
| float | targetY1, | ||
| float | sourceX2, | ||
| float | sourceY2, | ||
| float | targetX2, | ||
| float | targetY2, | ||
| float | sourceX3, | ||
| float | sourceY3, | ||
| float | targetX3, | ||
| float | targetY3 | ||
| ) | [static] |
Returns the transform that will map three specified points onto three target points.
| AffineTransform AffineTransform::followedBy | ( | const AffineTransform & | other ) | const |
Returns the result of concatenating another transformation after this one.
| bool AffineTransform::isIdentity | ( | ) | const |
Returns true if this transform has no effect on points.
| bool AffineTransform::isSingularity | ( | ) | const |
Returns true if this transform maps to a singularity - i.e.
if it has no inverse.
| bool AffineTransform::isOnlyTranslation | ( | ) | const |
Returns true if the transform only translates, and doesn't scale or rotate the points.
| float AffineTransform::getTranslationX | ( | ) | const |
If this transform is only a translation, this returns the X offset.
| float AffineTransform::getTranslationY | ( | ) | const |
If this transform is only a translation, this returns the X offset.
| float AffineTransform::getScaleFactor | ( | ) | const |
Returns the approximate scale factor by which lengths will be transformed.
Obviously a length may be scaled by entirely different amounts depending on its direction, so this is only appropriate as a rough guide.
const AffineTransform AffineTransform::identity [static] |
A ready-to-use identity transform, which you can use to append other transformations to.
e.g.
AffineTransform myTransform = AffineTransform::identity.rotated (.5f) .scaled (2.0f);
| float AffineTransform::mat00 |
| float AffineTransform::mat01 |
| float AffineTransform::mat02 |
| float AffineTransform::mat10 |
| float AffineTransform::mat11 |
| float AffineTransform::mat12 |