[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::Basis2< Real > Class Template Reference

#include <nnm.hpp>

Public Member Functions

constexpr Basis2 ()
template<typename Other>
constexpr Basis2 (const Basis2< Other > &basis)
constexpr Basis2 (const Matrix2< Real > &matrix)
constexpr Real trace () const
constexpr Real determinant () const
constexpr Basis2 unchecked_inverse () const
constexpr std::optional< Basis2inverse () const
constexpr bool valid () const
Basis2 rotate (const Real angle) const
Basis2 rotate_local (const Real angle) const
constexpr Basis2 scale (const Vector2< Real > &factor) const
constexpr Basis2 scale_local (const Vector2< Real > &factor) const
constexpr Basis2 shear_x (const Real factor) const
constexpr Basis2 shear_x_local (const Real factor) const
constexpr Basis2 shear_y (const Real factor) const
constexpr Basis2 shear_y_local (const Real factor) const
constexpr Basis2 transform (const Basis2 &by) const
constexpr Basis2 transform_local (const Basis2 &by) const
constexpr bool approx_equal (const Basis2 &other) const
constexpr const Vector2< Real > & at (const uint8_t column) const
constexpr Vector2< 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 Vector2< Real > & operator[] (const uint8_t index) const
constexpr Vector2< Real > & operator[] (const uint8_t index)
constexpr bool operator== (const Basis2 &other) const
constexpr bool operator!= (const Basis2 &other) const
constexpr bool operator< (const Basis2 &other) const

Static Public Member Functions

static Basis2 from_rotation (const Real angle)
static constexpr Basis2 from_scale (const Vector2< Real > &factor)
static constexpr Basis2 from_shear_x (const Real factor)
static constexpr Basis2 from_shear_y (const Real factor)

Public Attributes

Matrix2< Real > matrix

Detailed Description

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

Two-dimensional basis matrix.

Template Parameters
RealFloating-point type.

Constructor & Destructor Documentation

◆ Basis2() [1/3]

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

Initialize with identity basis.

◆ Basis2() [2/3]

template<typename Real>
template<typename Other>
nnm::Basis2< Real >::Basis2 ( const Basis2< Other > & basis)
inlineexplicitconstexpr

Cast from other basis type.

Template Parameters
OtherOther type.
Parameters
basisBasis to cast from.

◆ Basis2() [3/3]

template<typename Real>
nnm::Basis2< Real >::Basis2 ( const Matrix2< Real > & matrix)
inlineexplicitconstexpr

Initialize from 2x2 matrix. No validation is done.

Parameters
matrix2x2 matrix to cast from.

Member Function Documentation

◆ approx_equal()

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

If approximately equal to another basis.

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

◆ at() [1/4]

template<typename Real>
Vector2< Real > & nnm::Basis2< Real >::at ( const uint8_t column)
inlineconstexpr

Reference to the matrix column at index.

Parameters
columnColumn.
Returns
Reference.

◆ at() [2/4]

template<typename Real>
const Vector2< Real > & nnm::Basis2< Real >::at ( const uint8_t column) const
inlinenodiscardconstexpr

Constant reference to the matrix column at index.

Parameters
columnColumn
Returns
Constant reference.

◆ at() [3/4]

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

Reference to the matrix element at column and row.

Parameters
columnColumn.
rowRow.
Returns
Reference.

◆ at() [4/4]

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

Constant reference to the matrix element at column and row.

Parameters
columnColumn.
rowRow.
Returns
Constant reference.

◆ determinant()

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

Determinant.

Returns
Result.

◆ from_rotation()

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

Basis rotate by angle in radians.

Parameters
angleAngle in radians.
Returns
Result.

◆ from_scale()

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

Basis scaled by factor.

Parameters
factorScale factor.
Returns
Result.

◆ from_shear_x()

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

Basis sheared along the x-axis.

Parameters
factorFactor.
Returns
Result.

◆ from_shear_y()

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

Basis sheared along the y-axis.

Parameters
factorFactor.
Returns
Result.

◆ inverse()

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

Inverse which returns null if the basis is invalid.

Returns
Inverse if there is one, null if not.

◆ operator!=()

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

Element-wise inequality.

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

◆ operator<()

template<typename Real>
bool nnm::Basis2< Real >::operator< ( const Basis2< Real > & other) const
inlineconstexpr

Lexicographical comparison between the matrix elements.

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

◆ operator==()

template<typename Real>
bool nnm::Basis2< Real >::operator== ( const Basis2< Real > & other) const
inlineconstexpr

Element-wise equality.

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

◆ operator[]() [1/2]

template<typename Real>
Vector2< Real > & nnm::Basis2< Real >::operator[] ( const uint8_t index)
inlineconstexpr

Reference to the matrix column at index.

Parameters
indexIndex.
Returns
Reference.

◆ operator[]() [2/2]

template<typename Real>
const Vector2< Real > & nnm::Basis2< Real >::operator[] ( const uint8_t index) const
inlineconstexpr

Constant reference to the matrix column at index.

Parameters
indexIndex.
Returns
Constant reference.

◆ rotate()

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

Rotate by angle.

Parameters
angleAngle in radians.
Returns
Result.

◆ rotate_local()

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

Local rotation by angle.

Parameters
angleAngle in radians.
Returns
Result.

◆ scale()

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

Scale by factor.

Parameters
factorScale factor.
Returns
Result.

◆ scale_local()

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

Local scale by factor.

Parameters
factorScale factor.
Returns
Result.

◆ shear_x()

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

Shear along x-axis.

Parameters
factorFactor.
Returns
Result.

◆ shear_x_local()

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

Local shear along x-axis.

Parameters
factorFactor.
Returns
Result.

◆ shear_y()

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

Shear along y-axis.

Parameters
factorFactor.
Returns
Result.

◆ shear_y_local()

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

Local shear along y-axis.

Parameters
factorFactor.
Returns
Result.

◆ trace()

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

Trace which is the sum of the diagonal of the matrix.

Returns
Result.

◆ transform()

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

Transform by another basis.

Parameters
byBasis to transform by.
Returns
Result.

◆ transform_local()

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

Local transform by another basis.

Parameters
byBasis to transform by.
Returns
Result.

◆ unchecked_inverse()

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

Inverse without checking if the basis is valid first.

Returns
Result.

◆ valid()

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

If the elements of the matrix form a valid basis.

Returns
True if valid, false otherwise.

Member Data Documentation

◆ matrix

template<typename Real>
Matrix2<Real> nnm::Basis2< Real >::matrix

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