[nnm] No Nonsense Math 0.5.0
A No-Nonsense, C++ 17, single-header-only Math library geared towards graphics programming.
Loading...
Searching...
No Matches
nnm::Transform2< Real > Class Template Reference

#include <nnm.hpp>

Public Member Functions

constexpr Transform2 ()
template<typename Other>
constexpr Transform2 (const Transform2< Other > &transform)
constexpr Transform2 (const Matrix3< Real > &matrix)
constexpr Real trace () const
constexpr Real determinant () const
constexpr Transform2 unchecked_inverse () const
constexpr std::optional< Transform2inverse () const
constexpr bool valid () const
constexpr bool affine () const
constexpr Basis2< Real > basis () const
constexpr Vector2< Real > translation () const
constexpr Transform2 translate (const Vector2< Real > &offset) const
constexpr Transform2 translate_local (const Vector2< Real > &offset) const
Transform2 rotate (const Real angle) const
Transform2 rotate_local (const Real angle) const
constexpr Transform2 scale (const Vector2< Real > &factor) const
constexpr Transform2 scale_local (const Vector2< Real > &factor) const
constexpr Transform2 shear_x (const Real factor) const
constexpr Transform2 shear_x_local (const Real factor) const
constexpr Transform2 shear_y (const Real factor) const
constexpr Transform2 shear_y_local (const Real factor) const
constexpr Transform2 transform (const Transform2 &by) const
constexpr Transform2 transform_local (const Transform2 &by) const
constexpr bool approx_equal (const Transform2 &other) const
constexpr const Vector3< Real > & at (const uint8_t column) const
constexpr Vector3< Real > & at (const uint8_t column)
constexpr const Real & at (const uint8_t column, const uint8_t row) const
constexpr Real & at (const uint8_t column, const uint8_t row)
constexpr const Vector3< Real > & operator[] (const uint8_t column) const
constexpr Vector3< Real > & operator[] (const uint8_t column)
constexpr bool operator== (const Transform2 &other) const
constexpr bool operator!= (const Transform2 &other) const
constexpr bool operator< (const Transform2 &other) const

Static Public Member Functions

static constexpr Transform2 from_basis_translation (const Basis2< Real > &basis, const Vector2< Real > &translation)
static constexpr Transform2 from_basis (const Basis2< Real > &basis)
static constexpr Transform2 from_translation (const Vector2< Real > &translation)
static Transform2 from_rotation (const Real angle)
static constexpr Transform2 from_scale (const Vector2< Real > &factor)
static constexpr Transform2 from_shear_x (const Real factor)
static constexpr Transform2 from_shear_y (const Real factor)

Public Attributes

Matrix3< Real > matrix

Detailed Description

template<typename Real>
class nnm::Transform2< Real >

Two-dimensional transformation matrix.

Template Parameters
RealFloating-point type.

Constructor & Destructor Documentation

◆ Transform2() [1/3]

template<typename Real>
nnm::Transform2< Real >::Transform2 ( )
inlineconstexpr

Initialize with identity.

◆ Transform2() [2/3]

template<typename Real>
template<typename Other>
nnm::Transform2< Real >::Transform2 ( const Transform2< Other > & transform)
inlineexplicitconstexpr

Cast from other transform type.

Template Parameters
OtherOther transform type.
Parameters
transformTransform to cast from.

◆ Transform2() [3/3]

template<typename Real>
nnm::Transform2< Real >::Transform2 ( const Matrix3< Real > & matrix)
inlineexplicitconstexpr

Initialize from 3x3 matrix. No validation is done.

Parameters
matrix3x3 matrix.

Member Function Documentation

◆ affine()

template<typename Real>
bool nnm::Transform2< Real >::affine ( ) const
inlinenodiscardconstexpr

If the transform is affine. A transform is affine if all lines remain straight and parallel lines are preserved.

Returns
True if affine, false otherwise.

◆ approx_equal()

template<typename Real>
bool nnm::Transform2< Real >::approx_equal ( const Transform2< Real > & other) const
inlinenodiscardconstexpr

Element-wise approximately equal.

Parameters
otherOther transform.
Returns
True if approximately equal, false otherwise.

◆ at() [1/4]

template<typename Real>
Vector3< Real > & nnm::Transform2< Real >::at ( const uint8_t column)
inlineconstexpr

Reference to column

Parameters
columnColumn.
Returns
Reference.

◆ at() [2/4]

template<typename Real>
const Vector3< Real > & nnm::Transform2< Real >::at ( const uint8_t column) const
inlinenodiscardconstexpr

Constant reference to column at index.

Parameters
columnColumn.
Returns
Constant reference.

◆ at() [3/4]

template<typename Real>
Real & nnm::Transform2< Real >::at ( const uint8_t column,
const uint8_t row )
inlineconstexpr

Reference to element at column and row.

Parameters
columnColumn.
rowRow.
Returns
Reference.

◆ at() [4/4]

template<typename Real>
const Real & nnm::Transform2< Real >::at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Constant reference to element at column and row.

Parameters
columnColumn.
rowRow.
Returns
Constant reference.

◆ basis()

template<typename Real>
Basis2< Real > nnm::Transform2< Real >::basis ( ) const
inlinenodiscardconstexpr

Two-dimensional basis sub-matrix.

Returns
Basis.

◆ determinant()

template<typename Real>
Real nnm::Transform2< Real >::determinant ( ) const
inlinenodiscardconstexpr

Determinant.

Returns
Result.

◆ from_basis()

template<typename Real>
constexpr Transform2 nnm::Transform2< Real >::from_basis ( const Basis2< Real > & basis)
inlinestaticconstexpr

Transform with basis.

Parameters
basisBasis.
Returns
Result.

◆ from_basis_translation()

template<typename Real>
constexpr Transform2 nnm::Transform2< Real >::from_basis_translation ( const Basis2< Real > & basis,
const Vector2< Real > & translation )
inlinestaticconstexpr

Transform from two-dimensional basis and two-dimension translation. No validation is done.

Parameters
basisBasis.
translationTranslation.
Returns
Result.

◆ from_rotation()

template<typename Real>
Transform2 nnm::Transform2< Real >::from_rotation ( const Real angle)
inlinestatic

Transform with rotation.

Parameters
angleAngle in radians.
Returns
Result.

◆ from_scale()

template<typename Real>
constexpr Transform2 nnm::Transform2< Real >::from_scale ( const Vector2< Real > & factor)
inlinestaticconstexpr

Transform with scale.

Parameters
factorScale factor.
Returns
Result.

◆ from_shear_x()

template<typename Real>
constexpr Transform2 nnm::Transform2< Real >::from_shear_x ( const Real factor)
inlinestaticconstexpr

Transform with shear along x-axis.

Parameters
factorFactor.
Returns
Result.

◆ from_shear_y()

template<typename Real>
constexpr Transform2 nnm::Transform2< Real >::from_shear_y ( const Real factor)
inlinestaticconstexpr

Transform with shear along y-axis.

Parameters
factorfactor.
Returns
Result.

◆ from_translation()

template<typename Real>
constexpr Transform2 nnm::Transform2< Real >::from_translation ( const Vector2< Real > & translation)
inlinestaticconstexpr

Transform with translation

Parameters
translationTranslation
Returns
Result.

◆ inverse()

template<typename Real>
std::optional< Transform2 > nnm::Transform2< Real >::inverse ( ) const
inlinenodiscardconstexpr

Inverse which returns null if there is none.

Returns
Inverse if there is one, null if not.

◆ operator!=()

template<typename Real>
bool nnm::Transform2< Real >::operator!= ( const Transform2< Real > & other) const
inlinenodiscardconstexpr

Element-wise inequality.

Parameters
otherOther transform.
Returns
True if not equal, false otherwise.

◆ operator<()

template<typename Real>
bool nnm::Transform2< Real >::operator< ( const Transform2< Real > & other) const
inlinenodiscardconstexpr

Lexicographical comparison between elements.

Parameters
otherOther transform.
Returns
True if less than, false otherwise.

◆ operator==()

template<typename Real>
bool nnm::Transform2< Real >::operator== ( const Transform2< Real > & other) const
inlinenodiscardconstexpr

Element-wise equality.

Parameters
otherOther transform.
Returns
True if equal, false otherwise.

◆ operator[]() [1/2]

template<typename Real>
Vector3< Real > & nnm::Transform2< Real >::operator[] ( const uint8_t column)
inlineconstexpr

Reference to column at index.

Parameters
columnColumn.
Returns
Reference.

◆ operator[]() [2/2]

template<typename Real>
const Vector3< Real > & nnm::Transform2< Real >::operator[] ( const uint8_t column) const
inlinenodiscardconstexpr

Constant reference to column at index.

Parameters
columnColumn.
Returns
Constant reference.

◆ rotate()

template<typename Real>
Transform2 nnm::Transform2< Real >::rotate ( const Real angle) const
inlinenodiscard

Rotate by angle.

Parameters
angleAngle in radians.
Returns
Result.

◆ rotate_local()

template<typename Real>
Transform2 nnm::Transform2< Real >::rotate_local ( const Real angle) const
inlinenodiscard

Local rotate by angle.

Parameters
angleAngle in radians.
Returns
Result.

◆ scale()

template<typename Real>
Transform2 nnm::Transform2< Real >::scale ( const Vector2< Real > & factor) const
inlinenodiscardconstexpr

Scale by factor.

Parameters
factorScale factor.
Returns
Result.

◆ scale_local()

template<typename Real>
Transform2 nnm::Transform2< Real >::scale_local ( const Vector2< Real > & factor) const
inlinenodiscardconstexpr

Local scale by factor.

Parameters
factorScale factor.
Returns
Result.

◆ shear_x()

template<typename Real>
Transform2 nnm::Transform2< Real >::shear_x ( const Real factor) const
inlinenodiscardconstexpr

Shear along x-axis.

Parameters
factorfactor.
Returns
Result.

◆ shear_x_local()

template<typename Real>
Transform2 nnm::Transform2< Real >::shear_x_local ( const Real factor) const
inlinenodiscardconstexpr

Local shear along x-axis.

Parameters
factorFactor.
Returns
Result.

◆ shear_y()

template<typename Real>
Transform2 nnm::Transform2< Real >::shear_y ( const Real factor) const
inlinenodiscardconstexpr

Shear along y-axis.

Parameters
factorFactor.
Returns
Result.

◆ shear_y_local()

template<typename Real>
Transform2 nnm::Transform2< Real >::shear_y_local ( const Real factor) const
inlinenodiscardconstexpr

Local shear along y-axis.

Parameters
factorFactor.
Returns
Result.

◆ trace()

template<typename Real>
Real nnm::Transform2< Real >::trace ( ) const
inlinenodiscardconstexpr

Trace which is the sum of the matrix diagonal.

Returns
Result.

◆ transform()

template<typename Real>
Transform2 nnm::Transform2< Real >::transform ( const Transform2< Real > & by) const
inlinenodiscardconstexpr

Transform by another transform.

Parameters
byTransform to transform by.
Returns
Result.

◆ transform_local()

template<typename Real>
Transform2 nnm::Transform2< Real >::transform_local ( const Transform2< Real > & by) const
inlinenodiscardconstexpr

Local transform by another transform.

Parameters
byTransform to transform by.
Returns
Result.

◆ translate()

template<typename Real>
Transform2 nnm::Transform2< Real >::translate ( const Vector2< Real > & offset) const
inlinenodiscardconstexpr

Translate.

Parameters
offsetOffset.
Returns
Result.

◆ translate_local()

template<typename Real>
Transform2 nnm::Transform2< Real >::translate_local ( const Vector2< Real > & offset) const
inlinenodiscardconstexpr

Local translate.

Parameters
offsetOffset.
Returns
Result.

◆ translation()

template<typename Real>
Vector2< Real > nnm::Transform2< Real >::translation ( ) const
inlinenodiscardconstexpr

Translation of the transform.

Returns
Resulting two-dimensional translation vector.

◆ unchecked_inverse()

template<typename Real>
Transform2 nnm::Transform2< Real >::unchecked_inverse ( ) const
inlinenodiscardconstexpr

Inverse without checking if there is one.

Returns
Result.

◆ valid()

template<typename Real>
bool nnm::Transform2< Real >::valid ( ) const
inlinenodiscardconstexpr

If the transform is valid.

Returns
True if valid, false otherwise.

Member Data Documentation

◆ matrix

template<typename Real>
Matrix3<Real> nnm::Transform2< Real >::matrix

The documentation for this class was generated from the following file: