A 2D matrix representing an affine transformation. More...
#include "donner/base/Transform.h"
Classes | |
| struct | UninitializedTag |
| Tag type for constructing an uninitialized transform. More... | |
Public Member Functions | |
| Transform2 () | |
| Construct an identity transform. | |
| Transform2 (UninitializedTag) | |
| Construct an uninitialized transform. | |
| ~Transform2 ()=default | |
| Destructor. | |
| Transform2 (const Transform2< T > &)=default | |
| Copy constructor. | |
| Transform2 (Transform2< T > &&)=default | |
| Move constructor. | |
| Transform2< T > & | operator= (const Transform2< T > &)=default |
| Copy assignment operator. | |
| Transform2< T > & | operator= (Transform2< T > &&)=default |
| Move assignment operator. | |
| bool | isIdentity () const |
| Returns true if this transform is equal to the identity matrix. | |
| bool | isTranslation () const |
| Returns true if this transform is a pure translation (no rotation, scale, or skew). | |
| Vector2< T > | translation () const |
| Returns the translation component of this transform as a vector. | |
| T | determinant () const |
| Returns the determinant. | |
| Transform2< T > | inverse () const |
| Returns the inverse of this transform. | |
| Vector2< T > | transformVector (const Vector2< T > &v) const |
| Transforms a column vector, applying rotations/scaling but not translation. | |
| Vector2< T > | transformPosition (const Vector2< T > &v) const |
| Transforms a position given as a vector. | |
| Box2< T > | transformBox (const Box2< T > &box) const |
| Transform an axis-aligned bounding box, returning a new axis-aligned bounding box with the result. | |
| Transform2< T > | operator* (const Transform2< T > &rhs) const |
Composes two transforms: the result applies this transform first, then rhs. | |
| bool | operator== (const Transform2< T > &rhs) const |
| Exact element-wise equality. | |
Static Public Member Functions | |
| static Transform2 | Rotate (T angleRadians) |
| Return a 2D rotation matrix with the given angle, in radians. | |
| static Transform2 | Scale (T extent) |
| Return a 2D scale matrix with uniform scaling. | |
| static Transform2 | Scale (const Vector2< T > &extent) |
| Return a 2D scale matrix with horizontal and vertical scaling from a Vector2. | |
| static Transform2 | Scale (T x, T y) |
| Return a 2D scale matrix with horizontal and vertical scaling, convenience API accepting two parameters. | |
| static Transform2 | Translate (const Vector2< T > &offset) |
| Return a 2D translation matrix. | |
| static Transform2 | Translate (T x, T y) |
| Return a 2D translation matrix, convenience API accepting two parameters. | |
| static Transform2 | SkewX (T theta) |
| Returns a 2D skew transformation along the X axis. | |
| static Transform2 | SkewY (T theta) |
| Returns a 2D skew transformation along the Y axis. | |
Public Attributes | |
| T | data [6] |
| Storage for a 3x2 matrix, in column-major order. | |
Static Public Attributes | |
| static constexpr const UninitializedTag | uninitialized = UninitializedTag() |
| Tag value for constructing an uninitialized transform. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const Transform2< T > &t) |
| Ostream output operator. | |
A 2D matrix representing an affine transformation.
It stores six parameters, and is equivalent to the 3x3 matrix:
\[\begin{bmatrix} a & c & e \\ b & d & f \\ 0 & 0 & 1 \\ \end{bmatrix} \]
Elements are stored in column-major order.
| T | Element type. |
| struct donner::Transform2::UninitializedTag |
Tag type for constructing an uninitialized transform.
|
inlineexplicit |
Construct an uninitialized transform.
|
inline |
Returns the inverse of this transform.
If the determinant is zero, the result contains non-finite values.
|
inline |
Returns true if this transform is a pure translation (no rotation, scale, or skew).
A pure translation has the form:
\[\begin{bmatrix} 1 & 0 & e \\ 0 & 1 & f \\ 0 & 0 & 1 \\ \end{bmatrix} \]
|
inline |
Composes two transforms: the result applies this transform first, then rhs.
Example: Take A, transform by T, transform by R is written as
| rhs | Transform applied after this one. |
|
inline |
Exact element-wise equality.
No epsilon: this is the comparison a cache key needs, where any difference in the producing transform means the cached derivative has to be rebuilt. Compare with an explicit tolerance instead when the two transforms went through different arithmetic.
| rhs | Other transform. |
|
inlinestatic |
Return a 2D rotation matrix with the given angle, in radians.
| angleRadians | Angle in radians. |
|
inlinestatic |
Return a 2D scale matrix with horizontal and vertical scaling from a Vector2.
| extent | Scale x/y parameters. |
|
inlinestatic |
Return a 2D scale matrix with uniform scaling.
| extent | Scale x/y parameters. |
|
inlinestatic |
Return a 2D scale matrix with horizontal and vertical scaling, convenience API accepting two parameters.
| x | Horizontal scale. |
| y | Vertical scale. |
|
inlinestatic |
Returns a 2D skew transformation along the X axis.
| theta | Angle in radians. |
|
inlinestatic |
Returns a 2D skew transformation along the Y axis.
| theta | Angle in radians. |
|
inline |
Transform an axis-aligned bounding box, returning a new axis-aligned bounding box with the result.
| box | Box to transform. |
|
inline |
Transforms a position given as a vector.
\[ v' = M \begin{bmatrix} v_x \\ v_y \\ 1 \end{bmatrix} \]
| v | Vector to transform. |
|
inline |
Transforms a column vector, applying rotations/scaling but not translation.
\[ v' = M \begin{bmatrix} v_x \\ v_y \\ 0 \end{bmatrix} \]
| v | Vector to transform. |
|
inlinestatic |
Return a 2D translation matrix.
| offset | Translation offset. |
|
inlinestatic |
Return a 2D translation matrix, convenience API accepting two parameters.
| x | Horizontal translation offset. |
| y | Vertical translation offset. |
| T donner::Transform2< T >::data[6] |
Storage for a 3x2 matrix, in column-major order.
Elements are stored in the following order: