|
|
Donner
C++20 SVG rendering library
|
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 | |
| Transform () | |
| Construct an identity transform. | |
| Transform (UninitializedTag) | |
| Construct an uninitialized transform. | |
| ~Transform ()=default | |
| Destructor. | |
| Transform (const Transform< T > &)=default | |
| Copy constructor. | |
| Transform (Transform< T > &&)=default | |
| Move constructor. | |
| Transform< T > & | operator= (const Transform< T > &)=default |
| Copy assignment operator. | |
| Transform< T > & | operator= (Transform< T > &&)=default |
| Move assignment operator. | |
| bool | isIdentity () const |
| Returns true if this transform is equal to the identity matrix. | |
| T | determinant () const |
| Returns the determinant. | |
| Transform< 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. | |
| Box< T > | transformBox (const Box< T > &box) const |
| Transform an axis-aligned bounding box, returning a new axis-aligned bounding box with the result. | |
| Transform< T > | operator* (const Transform< T > &rhs) const |
| Post-multiplies rhs with this transform. | |
Static Public Member Functions | |
| static Transform | Rotate (T angleRadians) |
| Return a 2D rotation matrix with the given angle, in radians. | |
| static Transform | Scale (T extent) |
| Return a 2D scale matrix with uniform scaling. | |
| static Transform | Scale (const Vector2< T > &extent) |
| Return a 2D scale matrix with horizontal and vertical scaling from a Vector2. | |
| static Transform | Scale (T x, T y) |
| Return a 2D scale matrix with horizontal and vertical scaling, convenience API accepting two parameters. | |
| static Transform | Translate (const Vector2< T > &offset) |
| Return a 2D translation matrix. | |
| static Transform | Translate (T x, T y) |
| Return a 2D translation matrix, convenience API accepting two parameters. | |
| static Transform | SkewX (T theta) |
| Returns a 2D skew transformation along the X axis. | |
| static Transform | 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 Transform< 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::Transform::UninitializedTag |
Tag type for constructing an uninitialized transform.
|
inlineexplicit |
Construct an uninitialized transform.
|
inline |
Post-multiplies rhs with this transform.
Example: Take A, transform by T, transform by R is written as
| rhs | Other transform. |
|
inlinestatic |
Return a 2D rotation matrix with the given angle, in radians.
| theta | 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 |
|
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::Transform< T >::data[6] |
Storage for a 3x2 matrix, in column-major order.
Elements are stored in the following order: