![]() |
Pangolin
Header-only C++20 plane computational geometry library
|
Affine transformation stored as a 2x3 matrix. More...
#include <transformation.hpp>
Public Types | |
| using | NumberType = Number |
Public Member Functions | |
| constexpr | Transformation ()=default |
| Creates the identity transformation. | |
| constexpr | Transformation (Number a, Number b, Number c, Number d, Number tx=Number{}, Number ty=Number{}) |
| Creates a transformation from its matrix entries. | |
| template<class OtherNumber> | |
| constexpr | Transformation (const Transformation< OtherNumber > &other) |
| Converts a transformation with a different entry type. | |
| constexpr Number | a () const |
| Returns the row-0, column-0 matrix entry. | |
| constexpr Number | b () const |
| Returns the row-0, column-1 matrix entry. | |
| constexpr Number | c () const |
| Returns the row-1, column-0 matrix entry. | |
| constexpr Number | d () const |
| Returns the row-1, column-1 matrix entry. | |
| constexpr Number | tx () const |
| Returns the translation added to the first coordinate. | |
| constexpr Number | ty () const |
| Returns the translation added to the second coordinate. | |
| constexpr auto | determinant () const |
| Returns the determinant of the linear (non-translation) part. | |
| constexpr bool | isInvertible () const |
| Tests whether the transformation has an inverse. | |
| template<class ResultNumber = division_result_t<NumberType>> | |
| constexpr Transformation< ResultNumber > | inverse () const |
| Returns the inverse transformation. | |
| template<class OtherNumber> | |
| constexpr auto | operator* (const Transformation< OtherNumber > &other) const |
Composes two transformations: (*this) * other applies other first, then *this. | |
| constexpr bool | operator== (const Transformation &) const =default |
| Compares the matrix entries for equality. | |
Static Public Member Functions | |
| static constexpr Transformation | identity () |
| Returns the identity transformation. | |
| static constexpr Transformation | translation (Number dx, Number dy) |
| Returns a translation by (dx, dy). | |
| static constexpr Transformation | scaling (Number sx, Number sy) |
| Returns a non-uniform scaling around the origin. | |
| static constexpr Transformation | scaling (Number s) |
| Returns a uniform scaling around the origin. | |
| static constexpr Transformation | rotation90 (int k=1) |
| Returns a rotation around the origin by 90k degrees. | |
| static constexpr Transformation | shearX (Number k) |
| Returns a horizontal shear: (x, y) -> (x + k*y, y). | |
| static constexpr Transformation | shearY (Number k) |
| Returns a vertical shear: (x, y) -> (x, y + k*x). | |
| static constexpr Transformation | reflectionX () |
| Returns a reflection across the x-axis. | |
| static constexpr Transformation | reflectionY () |
| Returns a reflection across the y-axis. | |
| template<std::floating_point ResultNumber = double> | |
| static Transformation< ResultNumber > | rotation (ResultNumber radians) |
| Returns a rotation around the origin by an arbitrary angle. | |
Affine transformation stored as a 2x3 matrix.
Affine transformation of the plane, stored as a 2x3 matrix.
Applied to a point or shape with operator*; composed with another transformation with operator* as well.
| Number | Matrix entry / coordinate type. |
| Number | Matrix entry / coordinate type. |
| using pgl::Transformation< Number >::NumberType = Number |
Type of the matrix entries.
|
constexprdefault |
Creates the identity transformation.
|
inlineconstexpr |
Creates a transformation from its matrix entries.
| a | Row 0, column 0 of the linear part. |
| b | Row 0, column 1 of the linear part. |
| c | Row 1, column 0 of the linear part. |
| d | Row 1, column 1 of the linear part. |
| tx | Translation added to the first coordinate. |
| ty | Translation added to the second coordinate. |
|
inlineconstexpr |
Converts a transformation with a different entry type.
| OtherNumber | Entry type of the source transformation. |
| other | Source transformation. |
|
inlineconstexpr |
Returns the row-0, column-0 matrix entry.
|
inlineconstexpr |
Returns the row-0, column-1 matrix entry.
|
inlineconstexpr |
Returns the row-1, column-0 matrix entry.
|
inlineconstexpr |
Returns the row-1, column-1 matrix entry.
|
inlineconstexpr |
Returns the determinant of the linear (non-translation) part.
Negative when the transformation reverses orientation (a reflection or an odd number of shears/reflections composed together), zero when it collapses the plane onto a line or point.
|
inlinestaticconstexpr |
Returns the identity transformation.
|
inlineconstexpr |
Returns the inverse transformation.
| ResultNumber | Matrix entry type of the result (default: division_result_t). |
ResultNumber is a type such as Rational<Number> that represents the division exactly.
|
inlineconstexpr |
Tests whether the transformation has an inverse.
|
inlineconstexpr |
Composes two transformations: (*this) * other applies other first, then *this.
| OtherNumber | Entry type of other. |
|
constexprdefault |
Compares the matrix entries for equality.
|
inlinestaticconstexpr |
Returns a reflection across the x-axis.
|
inlinestaticconstexpr |
Returns a reflection across the y-axis.
|
inlinestatic |
Returns a rotation around the origin by an arbitrary angle.
Unlike rotation90, an arbitrary angle is generally irrational, so this requires an explicit floating-point ResultNumber: there is no exact-by-default overload to silently fall back from.
| ResultNumber | Floating-point matrix entry type of the result. |
| radians | Rotation angle in radians. |
|
inlinestaticconstexpr |
Returns a rotation around the origin by 90k degrees.
Exact for every NumberType since the matrix entries are 0, 1, or -1.
| k | Number of 90-degree CCW rotations (may be negative). |
|
inlinestaticconstexpr |
Returns a uniform scaling around the origin.
| s | Factor applied to both coordinates. |
|
inlinestaticconstexpr |
Returns a non-uniform scaling around the origin.
| sx | Factor applied to the x coordinate. |
| sy | Factor applied to the y coordinate. |
|
inlinestaticconstexpr |
Returns a horizontal shear: (x, y) -> (x + k*y, y).
|
inlinestaticconstexpr |
Returns a vertical shear: (x, y) -> (x, y + k*x).
|
inlinestaticconstexpr |
Returns a translation by (dx, dy).
|
inlineconstexpr |
Returns the translation added to the first coordinate.
|
inlineconstexpr |
Returns the translation added to the second coordinate.