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

#include <nnm.hpp>

Public Member Functions

constexpr Matrix4 ()
template<typename Other>
constexpr Matrix4 (const Matrix4< Other > &matrix)
constexpr Matrix4 (const Vector4< Real > &column0, const Vector4< Real > &column1, const Vector4< Real > &column2, const Vector4< Real > &column3)
constexpr Matrix4 (const Real col0_row0, const Real col0_row1, const Real col0_row2, const Real col0_row3, const Real col1_row0, const Real col1_row1, const Real col1_row2, const Real col1_row3, const Real col2_row0, const Real col2_row1, const Real col2_row2, const Real col2_row3, const Real col3_row0, const Real col3_row1, const Real col3_row2, const Real col3_row3)
constexpr Real trace () const
constexpr Real determinant () const
constexpr Matrix3< Real > minor_matrix_at (const uint8_t column, const uint8_t row) const
constexpr Real minor_at (const uint8_t column, const uint8_t row) const
constexpr Matrix4 minor () const
constexpr Real cofactor_at (const uint8_t column, const uint8_t row) const
constexpr Matrix4 cofactor () const
constexpr Matrix4 transpose () const
constexpr Matrix4 adjugate () const
constexpr Matrix4 unchecked_inverse () const
constexpr std::optional< Matrix4inverse () const
constexpr bool approx_equal (const Matrix4 &other) const
constexpr bool approx_zero () const
constexpr const Vector4< Real > & at (const uint8_t column) const
constexpr Vector4< 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)
const Real * begin () const
const Real * end () const
Real * begin ()
Real * end ()
constexpr const Vector4< Real > & operator[] (const uint8_t index) const
constexpr Vector4< Real > & operator[] (const uint8_t index)
constexpr bool operator== (const Matrix4 &other) const
constexpr bool operator!= (const Matrix4 &other) const
constexpr Matrix4 operator+ (const Matrix4 &other) const
constexpr Matrix4operator+= (const Matrix4 &other)
constexpr Matrix4 operator- (const Matrix4 &other) const
constexpr Matrix4operator-= (const Matrix4 &other)
constexpr Matrix4 operator* (const Matrix4 &other) const
constexpr Matrix4operator*= (const Matrix4 &other)
constexpr Vector4< Real > operator* (const Vector4< Real > &vector) const
constexpr Matrix4 operator* (const Real value) const
constexpr Matrix4operator*= (const Real value)
constexpr Matrix4 operator/ (const Real value) const
constexpr Matrix4operator/= (const Real value)
constexpr bool operator< (const Matrix4 &other) const
constexpr operator bool () const

Static Public Member Functions

static constexpr Matrix4 all (const Real value)
static constexpr Matrix4 zero ()
static constexpr Matrix4 one ()
static constexpr Matrix4 identity ()

Public Attributes

Vector4< Real > columns [4]

Detailed Description

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

4x4 matrix.

Template Parameters
RealFloating-point type.

Constructor & Destructor Documentation

◆ Matrix4() [1/4]

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

Initialize with identity matrix.

◆ Matrix4() [2/4]

template<typename Real>
template<typename Other>
nnm::Matrix4< Real >::Matrix4 ( const Matrix4< Other > & matrix)
inlineexplicitconstexpr

Casts from another matrix.

Template Parameters
OtherOther type to cast from.
Parameters
matrixOther matrix.

◆ Matrix4() [3/4]

template<typename Real>
nnm::Matrix4< Real >::Matrix4 ( const Vector4< Real > & column0,
const Vector4< Real > & column1,
const Vector4< Real > & column2,
const Vector4< Real > & column3 )
inlineconstexpr

Initialize with columns.

Parameters
column0First column.
column1Second column.
column2Third column.
column3Fourth column.

◆ Matrix4() [4/4]

template<typename Real>
nnm::Matrix4< Real >::Matrix4 ( const Real col0_row0,
const Real col0_row1,
const Real col0_row2,
const Real col0_row3,
const Real col1_row0,
const Real col1_row1,
const Real col1_row2,
const Real col1_row3,
const Real col2_row0,
const Real col2_row1,
const Real col2_row2,
const Real col2_row3,
const Real col3_row0,
const Real col3_row1,
const Real col3_row2,
const Real col3_row3 )
inlineconstexpr

Initialize with elements.

Parameters
col0_row0First column, first row.
col0_row1First column, second row.
col0_row2First column, third row.
col0_row3First column, fourth row.
col1_row0Second column, first row.
col1_row1Second column, second row.
col1_row2Second column, third row.
col1_row3Second column, fourth row.
col2_row0Third column, first row.
col2_row1Third column, second row.
col2_row2Third column, third row.
col2_row3Third column, fourth row.
col3_row0Fourth column, first row.
col3_row1Fourth column, second row.
col3_row2Fourth column, third row.
col3_row3Fourth column, fourth row.

Member Function Documentation

◆ adjugate()

template<typename Real>
Matrix4 nnm::Matrix4< Real >::adjugate ( ) const
inlinenodiscardconstexpr

Adjugate matrix.

Returns
Result.

◆ all()

template<typename Real>
constexpr Matrix4 nnm::Matrix4< Real >::all ( const Real value)
inlinestaticnodiscardconstexpr

Matrix with all element set to value.

Parameters
valueValue.
Returns
Result.

◆ approx_equal()

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

Determines if approximately equal to another matrix.

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

◆ approx_zero()

template<typename Real>
bool nnm::Matrix4< Real >::approx_zero ( ) const
inlinenodiscardconstexpr

Determines if all elements are approximately zero.

Returns
True if approximately all zero, false otherwise.

◆ at() [1/4]

template<typename Real>
Vector4< Real > & nnm::Matrix4< 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 Vector4< Real > & nnm::Matrix4< 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::Matrix4< Real >::at ( const uint8_t column,
const uint8_t row )
inlineconstexpr

Reference to 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::Matrix4< Real >::at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Constant reference to element at index of column and row.

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

◆ begin() [1/2]

template<typename Real>
Real * nnm::Matrix4< Real >::begin ( )
inline

Start of iterator.

Returns
Iterator.

◆ begin() [2/2]

template<typename Real>
const Real * nnm::Matrix4< Real >::begin ( ) const
inlinenodiscard

Start of constant iterator.

Returns
Constant iterator.

◆ cofactor()

template<typename Real>
Matrix4 nnm::Matrix4< Real >::cofactor ( ) const
inlinenodiscardconstexpr

Cofactor matrix which is a matrix where each element is the cofactor at that element.

Returns
Result.

◆ cofactor_at()

template<typename Real>
Real nnm::Matrix4< Real >::cofactor_at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Cofactor at column and row.

Parameters
columnIndex of column.
rowIndex of row.
Returns
Result.

◆ determinant()

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

Determinant of matrix.

Returns
Result.

◆ end() [1/2]

template<typename Real>
Real * nnm::Matrix4< Real >::end ( )
inline

End of iterator

Returns
Iterator

◆ end() [2/2]

template<typename Real>
const Real * nnm::Matrix4< Real >::end ( ) const
inlinenodiscard

End of constant iterator.

Returns
Constant iterator.

◆ identity()

template<typename Real>
constexpr Matrix4 nnm::Matrix4< Real >::identity ( )
inlinestaticnodiscardconstexpr

Identity matrix.

Returns
Result.

◆ inverse()

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

Inverse matrix.

Returns
Inverse matrix if one exists, null otherwise.

◆ minor()

template<typename Real>
Matrix4 nnm::Matrix4< Real >::minor ( ) const
inlinenodiscardconstexpr

Minor matrix which is a matrix where each element is the minor at the element.

Returns
Result.

◆ minor_at()

template<typename Real>
Real nnm::Matrix4< Real >::minor_at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Minor at column and row which is the determinant of the minor matrix at the column and row.

Parameters
columnIndex of column.
rowIndex of row.
Returns
Result.

◆ minor_matrix_at()

template<typename Real>
Matrix3< Real > nnm::Matrix4< Real >::minor_matrix_at ( const uint8_t column,
const uint8_t row ) const
inlinenodiscardconstexpr

Minor matrix at column and row which is the matrix where the specified column and row are removed.

Parameters
columnIndex of column.
rowIndex of row.
Returns
Resulting 3x3 matrix.

◆ one()

template<typename Real>
constexpr Matrix4 nnm::Matrix4< Real >::one ( )
inlinestaticnodiscardconstexpr

Matrix with all elements set to one.

Returns
Result.

◆ operator bool()

template<typename Real>
nnm::Matrix4< Real >::operator bool ( ) const
inlineexplicitconstexpr

True if any elements are non-zero, false otherwise.

◆ operator!=()

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

Element-wise inequality.

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

◆ operator*() [1/3]

template<typename Real>
Matrix4 nnm::Matrix4< Real >::operator* ( const Matrix4< Real > & other) const
inlineconstexpr

Matrix multiplication.

Parameters
otherOther matrix.
Returns
Result.

◆ operator*() [2/3]

template<typename Real>
Matrix4 nnm::Matrix4< Real >::operator* ( const Real value) const
inlinenodiscardconstexpr

Matrix-scalar multiplication.

Parameters
valueScalar value.
Returns
Result.

◆ operator*() [3/3]

template<typename Real>
Vector4< Real > nnm::Matrix4< Real >::operator* ( const Vector4< Real > & vector) const
inlineconstexpr

Matrix-vector multiplication.

Parameters
vector4D vector.
Returns
Result.

◆ operator*=() [1/2]

template<typename Real>
Matrix4 & nnm::Matrix4< Real >::operator*= ( const Matrix4< Real > & other)
inlineconstexpr

Matrix multiplication.

Parameters
otherOther matrix.
Returns
Reference to this modified matrix.

◆ operator*=() [2/2]

template<typename Real>
Matrix4 & nnm::Matrix4< Real >::operator*= ( const Real value)
inlineconstexpr

Matrix-scalar multiplication.

Parameters
valueScalar value.
Returns
Reference to this modified matrix.

◆ operator+()

template<typename Real>
Matrix4 nnm::Matrix4< Real >::operator+ ( const Matrix4< Real > & other) const
inlinenodiscardconstexpr

Element-wise addition.

Parameters
otherOther matrix.
Returns
Result.

◆ operator+=()

template<typename Real>
Matrix4 & nnm::Matrix4< Real >::operator+= ( const Matrix4< Real > & other)
inlineconstexpr

Element-wise addition.

Parameters
otherOther matrix.
Returns
Reference to this modified matrix.

◆ operator-()

template<typename Real>
Matrix4 nnm::Matrix4< Real >::operator- ( const Matrix4< Real > & other) const
inlinenodiscardconstexpr

Element-wise subtraction.

Parameters
otherOther matrix.
Returns
Result.

◆ operator-=()

template<typename Real>
Matrix4 & nnm::Matrix4< Real >::operator-= ( const Matrix4< Real > & other)
inlineconstexpr

Element-wise subtraction.

Parameters
otherOther matrix.
Returns
Reference to this modified matrix.

◆ operator/()

template<typename Real>
Matrix4 nnm::Matrix4< Real >::operator/ ( const Real value) const
inlinenodiscardconstexpr

Element-wise division by value.

Parameters
valueValue.
Returns
Result.

◆ operator/=()

template<typename Real>
Matrix4 & nnm::Matrix4< Real >::operator/= ( const Real value)
inlineconstexpr

Element-wise division by value.

Parameters
valueValue.
Returns
Reference to this modified matrix.

◆ operator<()

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

Lexicographical comparison with another matrix.

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

◆ operator==()

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

Element-wise equality.

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

◆ operator[]() [1/2]

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

Reference to column at index.

Parameters
index
Returns

◆ operator[]() [2/2]

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

Constant reference to column at index.

Parameters
indexIndex of column.
Returns
Constant reference to column.

◆ trace()

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

Trace which is the sum of the matrix diagonal.

Returns
Result.

◆ transpose()

template<typename Real>
Matrix4 nnm::Matrix4< Real >::transpose ( ) const
inlinenodiscardconstexpr

Transpose matrix.

Returns
Result.

◆ unchecked_inverse()

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

Inverse matrix without first checking if a valid inverse if possible.

Returns
Result.

◆ zero()

template<typename Real>
constexpr Matrix4 nnm::Matrix4< Real >::zero ( )
inlinestaticnodiscardconstexpr

Matrix with all elements set to zero.

Returns
Result.

Member Data Documentation

◆ columns

template<typename Real>
Vector4<Real> nnm::Matrix4< Real >::columns[4]

Columns of matrix.


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