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

#include <nnm.hpp>

Public Member Functions

constexpr Basis3 ()
template<typename Other>
constexpr Basis3 (const Basis3< Other > &basis)
constexpr Basis3 (const Matrix3< Real > &matrix)
constexpr Real trace () const
constexpr Real determinant () const
constexpr Basis3 unchecked_inverse () const
constexpr std::optional< Basis3inverse () const
constexpr bool valid () const
Basis3 rotate_axis_angle (const Vector3< Real > &axis, const Real angle) const
Basis3 rotate_axis_angle_local (const Vector3< Real > &axis, const Real angle) const
constexpr Basis3 rotate_quaternion (const Quaternion< Real > &quaternion) const
constexpr Basis3 rotate_quaternion_local (const Quaternion< Real > &quaternion) const
constexpr Basis3 scale (const Vector3< Real > &factor) const
constexpr Basis3 scale_local (const Vector3< Real > &factor) const
constexpr Basis3 shear_x (const Real factor_y, const Real factor_z) const
constexpr Basis3 shear_x_local (const Real factor_y, const Real factor_z) const
constexpr Basis3 shear_y (const Real factor_x, const Real factor_z) const
constexpr Basis3 shear_y_local (const Real factor_x, const Real factor_z) const
constexpr Basis3 shear_z (const Real factor_x, const Real factor_y) const
constexpr Basis3 shear_z_local (const Real factor_x, const Real factor_y) const
constexpr Basis3 transform (const Basis3 &by) const
constexpr Basis3 transform_local (const Basis3 &by) const
constexpr bool approx_equal (const Basis3 &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 index) const
constexpr Vector3< Real > & operator[] (const uint8_t index)
constexpr bool operator== (const Basis3 &other) const
constexpr bool operator!= (const Basis3 &other) const
constexpr bool operator< (const Basis3 &other) const

Static Public Member Functions

static Basis3 from_rotation_axis_angle (const Vector3< Real > &axis, const Real angle)
static constexpr Basis3 from_rotation_quaternion (const Quaternion< Real > &quaternion)
static constexpr Basis3 from_scale (const Vector3< Real > &factor)
static constexpr Basis3 from_shear_x (const Real factor_y, const Real factor_z)
static constexpr Basis3 from_shear_y (const Real factor_x, const Real factor_z)
static constexpr Basis3 from_shear_z (const Real factor_x, const Real factor_y)

Public Attributes

Matrix3< Real > matrix

Detailed Description

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

Three-dimensional basis matrix. Can represent three-dimensional scale, shear, and rotation.

Template Parameters
Real

Constructor & Destructor Documentation

◆ Basis3() [1/3]

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

Initializes with identity.

◆ Basis3() [2/3]

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

Casts from another basis type.

Template Parameters
OtherOther basis type.
Parameters
basisBasis to cast from.

◆ Basis3() [3/3]

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

Initialize from 3x3 matrix. No validation is done.

Parameters
matrix3x3 matrix.

Member Function Documentation

◆ approx_equal()

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

Determines if approximately equal to another basis.

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

◆ at() [1/4]

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

Reference to column at index.

Parameters
columnIndex of column.
Returns
Reference to column.

◆ at() [2/4]

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

Constant reference to column at index.

Parameters
columnIndex of column.
Returns
Constant reference to column.

◆ at() [3/4]

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

Reference of element at index of column and row.

Parameters
columnIndex of column.
rowIndex of row.
Returns
Reference to element.

◆ at() [4/4]

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

Constant reference of element at index of column and row.

Parameters
columnIndex of column.
rowIndex of row.
Returns
Constant reference to element.

◆ determinant()

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

Determinant of the matrix.

Returns
Result.

◆ from_rotation_axis_angle()

template<typename Real>
Basis3 nnm::Basis3< Real >::from_rotation_axis_angle ( const Vector3< Real > & axis,
const Real angle )
inlinestatic

Basis rotated from normalized axis and angle.

Parameters
axisNormalized axis.
angleAngle in radians.
Returns
Result.

◆ from_rotation_quaternion()

template<typename Real>
constexpr Basis3 nnm::Basis3< Real >::from_rotation_quaternion ( const Quaternion< Real > & quaternion)
inlinestaticconstexpr

Basis rotated from quaternion.

Parameters
quaternionQuaternion.
Returns
Result.

◆ from_scale()

template<typename Real>
constexpr Basis3 nnm::Basis3< Real >::from_scale ( const Vector3< Real > & factor)
inlinestaticconstexpr

Basis scaled by factor.

Parameters
factorScale factor.
Returns
Result.

◆ from_shear_x()

template<typename Real>
constexpr Basis3 nnm::Basis3< Real >::from_shear_x ( const Real factor_y,
const Real factor_z )
inlinestaticconstexpr

Basis sheared along the x-axis.

Parameters
factor_yY-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ from_shear_y()

template<typename Real>
constexpr Basis3 nnm::Basis3< Real >::from_shear_y ( const Real factor_x,
const Real factor_z )
inlinestaticconstexpr

Basis sheared along the y-axis.

Parameters
factor_xX-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ from_shear_z()

template<typename Real>
constexpr Basis3 nnm::Basis3< Real >::from_shear_z ( const Real factor_x,
const Real factor_y )
inlinestaticconstexpr

Basis sheared along the z-axis.

Parameters
factor_xX-Axis factor.
factor_yY-Axis factor.
Returns
Result.

◆ inverse()

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

Inverse of the basis.

Returns
Inverse basis if the basis is valid or null otherwise.

◆ operator!=()

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

Element-wise inequality with another basis.

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

◆ operator<()

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

Lexicographical comparison between elements.

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

◆ operator==()

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

Element-wise equality with another basis.

Parameters
otherOther basis.
Returns
True if all elements are equal, false otherwise.

◆ operator[]() [1/2]

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

Reference to column at index.

Parameters
indexIndex of column.
Returns
Reference to column.

◆ operator[]() [2/2]

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

Constant reference to column at index.

Parameters
indexIndex of column.
Returns
Constant reference to column.

◆ rotate_axis_angle()

template<typename Real>
Basis3 nnm::Basis3< Real >::rotate_axis_angle ( const Vector3< Real > & axis,
const Real angle ) const
inlinenodiscard

Rotate about an axis by an angle.

Parameters
axisNormalized axis vector.
angleAngle in radians.
Returns
Result.

◆ rotate_axis_angle_local()

template<typename Real>
Basis3 nnm::Basis3< Real >::rotate_axis_angle_local ( const Vector3< Real > & axis,
const Real angle ) const
inlinenodiscard

Local rotate about an axis by an angle.

Parameters
axisNormalize axis vector.
angleAngle in radians.
Returns
Result.

◆ rotate_quaternion()

template<typename Real>
Basis3 nnm::Basis3< Real >::rotate_quaternion ( const Quaternion< Real > & quaternion) const
inlinenodiscardconstexpr

Rotate by quaternion.

Parameters
quaternionQuaternion.
Returns
Result.

◆ rotate_quaternion_local()

template<typename Real>
Basis3 nnm::Basis3< Real >::rotate_quaternion_local ( const Quaternion< Real > & quaternion) const
inlinenodiscardconstexpr

Local rotate by quaternion.

Parameters
quaternionQuaternion.
Returns
Result.

◆ scale()

template<typename Real>
Basis3 nnm::Basis3< Real >::scale ( const Vector3< Real > & factor) const
inlinenodiscardconstexpr

Per-axis scale by factor.

Parameters
factorVector scale factor.
Returns
Result.

◆ scale_local()

template<typename Real>
Basis3 nnm::Basis3< Real >::scale_local ( const Vector3< Real > & factor) const
inlinenodiscardconstexpr

Local per-axis scale by factor.

Parameters
factorVector scale factor.
Returns
Result.

◆ shear_x()

template<typename Real>
Basis3 nnm::Basis3< Real >::shear_x ( const Real factor_y,
const Real factor_z ) const
inlinenodiscardconstexpr

Shear about x-axis.

Parameters
factor_yY-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_x_local()

template<typename Real>
Basis3 nnm::Basis3< Real >::shear_x_local ( const Real factor_y,
const Real factor_z ) const
inlinenodiscardconstexpr

Local shear about x-axis

Parameters
factor_yY-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_y()

template<typename Real>
Basis3 nnm::Basis3< Real >::shear_y ( const Real factor_x,
const Real factor_z ) const
inlinenodiscardconstexpr

Shear about y-axis.

Parameters
factor_xX-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_y_local()

template<typename Real>
Basis3 nnm::Basis3< Real >::shear_y_local ( const Real factor_x,
const Real factor_z ) const
inlinenodiscardconstexpr

Local shear about y-axis.

Parameters
factor_xX-Axis factor.
factor_zZ-Axis factor.
Returns
Result.

◆ shear_z()

template<typename Real>
Basis3 nnm::Basis3< Real >::shear_z ( const Real factor_x,
const Real factor_y ) const
inlinenodiscardconstexpr

Shear about z-axis.

Parameters
factor_xX-Axis factor.
factor_yY-Axis factor.
Returns
Result.

◆ shear_z_local()

template<typename Real>
Basis3 nnm::Basis3< Real >::shear_z_local ( const Real factor_x,
const Real factor_y ) const
inlinenodiscardconstexpr

Local shear about z-axis.

Parameters
factor_xX-Axis factor.
factor_yY-Axis factor.
Returns
Result.

◆ trace()

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

Trace which is the sum of the matrix diagonal.

Returns
Result.

◆ transform()

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

Transform by another basis.

Parameters
byBasis.
Returns
Result.

◆ transform_local()

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

Local transform by another basis.

Parameters
byBasis.
Returns
Result.

◆ unchecked_inverse()

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

Inverse without checking if the basis is valid first.

Returns
Result.

◆ valid()

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

Determines if the basis is valid.

Returns
True if valid, false otherwise.

Member Data Documentation

◆ matrix

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

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