SA_Maths
Sapphire Suite's C++ Maths Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
SA::Mat3< T, major > Struct Template Reference

Matrix 3x3 Sapphire-Maths class. More...

#include <Matrix3.hpp>

Inheritance diagram for SA::Mat3< T, major >:

Public Member Functions

template<typename TIn , MatrixMajor majorIn>
constexpr Mat3 (const Mat3< TIn, majorIn > &_other) noexcept
 Value constructor from another Mat3 type.
 
template<typename TIn , MatrixMajor majorIn>
constexpr Mat3 (const Mat4< TIn, majorIn > &_other) noexcept
 Value constructor from another Mat4 type.
 
constexpr bool IsZero () const noexcept
 Whether this matrix is a zero matrix.
 
constexpr bool IsIdentity () const noexcept
 Whether this matrix is an identity matrix.
 
constexpr bool Equals (const Mat3 &_other, T _epsilon=std::numeric_limits< T >::epsilon()) const noexcept
 Compare 2 Matrix.
 
constexpr bool operator== (const Mat3 &_rhs) const noexcept
 Compare 2 matrix equality.
 
constexpr bool operator!= (const Mat3 &_rhs) const noexcept
 Compare 2 matrix inequality.
 
T * Data () noexcept
 Getter of matrix data
 
const T * Data () const noexcept
  Const Getter of matrix data
 
T & At (uint32_t _index)
 Getter of Value at index.
 
const T & At (uint32_t _index) const
  Const Getter of Value at index.
 
T & At (uint32_t _x, uint32_t _y)
 Getter of Value at (x;y).
 
const T & At (uint32_t _x, uint32_t _y) const
  Const Getter of Value at (x;y).
 
T & operator[] (uint32_t _index)
 Access operator by index.
 
const T & operator[] (uint32_t _index) const
  Const Access operator by index.
 
Mat3Transpose () noexcept
 Transpose this matrix.
 
constexpr Mat3 GetTransposed () const noexcept
 Transpose this matrix.
 
Determinant () const noexcept
 Compute the determinant of the matrix.
 
Mat3Inverse ()
 Inverse this matrix.
 
Mat3 GetInversed () const
 Inverse this matrix.
 
template<typename TIn , MatrixMajor majorIn>
Mat3operator= (const Mat3< TIn, majorIn > _rhs) noexcept
 Assignment operator from another Mat3 type.
 
constexpr Mat3 operator- () const noexcept
 Getter of the opposite signed matrix.
 
template<typename TIn >
Mat3 operator* (TIn _scale) const noexcept
 Scale each matrix component by _scale.
 
template<typename TIn >
Mat3 operator/ (TIn _scale) const
  Inverse Scale each matrix component by _scale.
 
Mat3 operator+ (const Mat3 &_rhs) const noexcept
 Add term by term matrix values.
 
Mat3 operator- (const Mat3 &_rhs) const noexcept
 Subtract term by term matrix values.
 
Mat3 operator* (const Mat3 &_rhs) const noexcept
 Multiply matrices.
 
Mat3 operator/ (const Mat3 &_rhs) const
 Inverse multiply matrices.
 
Vec3< T > operator* (const Vec3< T > &_rhs) const noexcept
 transform this vector by this matrix.
 
template<typename TIn >
Mat3operator*= (TIn _scale) noexcept
 Scale each matrix component by _scale.
 
template<typename TIn >
Mat3operator/= (TIn _scale)
  Inverse Scale each matrix component by _scale.
 
Mat3operator+= (const Mat3 &_rhs) noexcept
 Add term by term matrix values.
 
Mat3operator-= (const Mat3 &_rhs) noexcept
 Subtract term by term matrix values.
 
Mat3operator*= (const Mat3 &_rhs) noexcept
 Multiply matrices.
 
Mat3operator/= (const Mat3 &_rhs)
 Inverse multiply matrices.
 

Static Public Member Functions

static Mat3 Lerp (const Mat3 &_start, const Mat3 &_end, float _alpha) noexcept
  Clamped Lerp from _start to _end at _alpha.
 
static Mat3 LerpUnclamped (const Mat3 &_start, const Mat3 &_end, float _alpha) noexcept
  Unclamped Lerp from _start to _end at _alpha.
 
static Mat3 MakeRotation (const Quat< T > &_rot) noexcept
 Make rotation matrix from quaternion.
 
static Mat3 MakeScale (const Vec3< T > &_scale) noexcept
 Make scale matrix from vector3.
 

Static Public Attributes

static const Mat3 Zero
 Zero Mat3 constant.
 
static const Mat3 Identity
 Identity Mat3 constant.
 

Detailed Description

template<typename T, MatrixMajor major = MatrixMajor::Default>
struct SA::Mat3< T, major >

Matrix 3x3 Sapphire-Maths class.

must be align at 32 for intrinsics.

Template Parameters
TType of the matrix.

Constructor & Destructor Documentation

◆ Mat3() [1/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
template<typename TIn , MatrixMajor majorIn>
constexpr SA::Mat3< T, major >::Mat3 ( const Mat3< TIn, majorIn > & _other)
constexprnoexcept

Value constructor from another Mat3 type.

Template Parameters
TInType of the input Mat3.
majorInMajor of the input Mat3.
Parameters
[in]_otherMat3 to construct from.

◆ Mat3() [2/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
template<typename TIn , MatrixMajor majorIn>
constexpr SA::Mat3< T, major >::Mat3 ( const Mat4< TIn, majorIn > & _other)
constexprnoexcept

Value constructor from another Mat4 type.

Template Parameters
TInType of the input Mat4.
majorInMajor of the input Mat3.
Parameters
[in]_otherMat4 to construct from.

Member Function Documentation

◆ At() [1/4]

template<typename T , MatrixMajor major = MatrixMajor::Default>
T & SA::Mat3< T, major >::At ( uint32_t _index)

Getter of Value at index.

Parameters
[in]_indexIndex to access.
Returns
element at index.

◆ At() [2/4]

template<typename T , MatrixMajor major = MatrixMajor::Default>
const T & SA::Mat3< T, major >::At ( uint32_t _index) const

Const Getter of Value at index.

Parameters
[in]_indexIndex to access.
Returns
element at index.

◆ At() [3/4]

template<typename T , MatrixMajor major = MatrixMajor::Default>
T & SA::Mat3< T, major >::At ( uint32_t _x,
uint32_t _y )

Getter of Value at (x;y).

Parameters
[in]_xrow index.
[in]_ycolumn index.
Returns
element at index.

◆ At() [4/4]

template<typename T , MatrixMajor major = MatrixMajor::Default>
const T & SA::Mat3< T, major >::At ( uint32_t _x,
uint32_t _y ) const

Const Getter of Value at (x;y).

Parameters
[in]_xrow index.
[in]_ycolumn index.
Returns
element at index.

◆ Data() [1/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
const T * SA::Mat3< T, major >::Data ( ) const
noexcept

Const Getter of matrix data

Returns
this matrix as a const T*.

◆ Data() [2/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
T * SA::Mat3< T, major >::Data ( )
noexcept

Getter of matrix data

Returns
this matrix as a T*.

◆ Determinant()

template<typename T , MatrixMajor major = MatrixMajor::Default>
T SA::Mat3< T, major >::Determinant ( ) const
noexcept

Compute the determinant of the matrix.

Returns
Determinant of this matrix.

◆ Equals()

template<typename T , MatrixMajor major = MatrixMajor::Default>
constexpr bool SA::Mat3< T, major >::Equals ( const Mat3< T, major > & _other,
T _epsilon = std::numeric_limits< T >::epsilon() ) const
constexprnoexcept

Compare 2 Matrix.

Parameters
[in]_otherOther matrix to compare to.
[in]_epsilonEpsilon value for threshold comparison.
Returns
Whether this and _other are equal.

◆ GetInversed()

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 SA::Mat3< T, major >::GetInversed ( ) const

Inverse this matrix.

Returns
new inversed matrix.

◆ GetTransposed()

template<typename T , MatrixMajor major = MatrixMajor::Default>
constexpr Mat3 SA::Mat3< T, major >::GetTransposed ( ) const
constexprnoexcept

Transpose this matrix.

Returns
new transposed matrix.

◆ Inverse()

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 & SA::Mat3< T, major >::Inverse ( )

Inverse this matrix.

Returns
self inversed matrix.

◆ IsIdentity()

template<typename T , MatrixMajor major = MatrixMajor::Default>
constexpr bool SA::Mat3< T, major >::IsIdentity ( ) const
constexprnoexcept

Whether this matrix is an identity matrix.

Returns
True if this is an identity matrix.

◆ IsZero()

template<typename T , MatrixMajor major = MatrixMajor::Default>
constexpr bool SA::Mat3< T, major >::IsZero ( ) const
constexprnoexcept

Whether this matrix is a zero matrix.

Returns
True if this is a zero matrix.

◆ Lerp()

template<typename T , MatrixMajor major = MatrixMajor::Default>
static Mat3 SA::Mat3< T, major >::Lerp ( const Mat3< T, major > & _start,
const Mat3< T, major > & _end,
float _alpha )
staticnoexcept

Clamped Lerp from _start to _end at _alpha.

Reference: https://en.wikipedia.org/wiki/Linear_interpolation

Parameters
_startStarting point of the lerp.
_endEnding point of the lerp.
_alphaAlpha of the lerp.
Returns
interpolation between _start and _end. return _start when _alpha == 0.0f and _end when _alpha == 1.0f.

◆ LerpUnclamped()

template<typename T , MatrixMajor major = MatrixMajor::Default>
static Mat3 SA::Mat3< T, major >::LerpUnclamped ( const Mat3< T, major > & _start,
const Mat3< T, major > & _end,
float _alpha )
staticnoexcept

Unclamped Lerp from _start to _end at _alpha.

Reference: https://en.wikipedia.org/wiki/Linear_interpolation

Parameters
_startStarting point of the lerp.
_endEnding point of the lerp.
_alphaAlpha of the lerp.
Returns
interpolation between _start and _end. return _start when _alpha == 0.0f and _end when _alpha == 1.0f.

◆ MakeRotation()

template<typename T , MatrixMajor major = MatrixMajor::Default>
static Mat3 SA::Mat3< T, major >::MakeRotation ( const Quat< T > & _rot)
staticnoexcept

Make rotation matrix from quaternion.

Parameters
[in]_rotquaternion to use for rotation.
Returns
rotation matrix.

◆ MakeScale()

template<typename T , MatrixMajor major = MatrixMajor::Default>
static Mat3 SA::Mat3< T, major >::MakeScale ( const Vec3< T > & _scale)
staticnoexcept

Make scale matrix from vector3.

Parameters
[in]_scaleVector for scaling.
Returns
scale matrix.

◆ operator!=()

template<typename T , MatrixMajor major = MatrixMajor::Default>
constexpr bool SA::Mat3< T, major >::operator!= ( const Mat3< T, major > & _rhs) const
constexprnoexcept

Compare 2 matrix inequality.

Parameters
[in]_rhsOther matrix to compare to.
Returns
Whether this and _rhs are non-equal.

◆ operator*() [1/3]

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 SA::Mat3< T, major >::operator* ( const Mat3< T, major > & _rhs) const
noexcept

Multiply matrices.

Parameters
[in]_rhsMatrix to multiply to.
Returns
new matrix result.

◆ operator*() [2/3]

template<typename T , MatrixMajor major = MatrixMajor::Default>
Vec3< T > SA::Mat3< T, major >::operator* ( const Vec3< T > & _rhs) const
noexcept

transform this vector by this matrix.

Parameters
[in]_rhsVector to transform.
Returns
Transformed vector.

◆ operator*() [3/3]

template<typename T , MatrixMajor major = MatrixMajor::Default>
template<typename TIn >
Mat3 SA::Mat3< T, major >::operator* ( TIn _scale) const
noexcept

Scale each matrix component by _scale.

Template Parameters
TInType of the input scale.
Parameters
[in]_scaleScale value to apply on all components.
Returns
new matrix scaled.

◆ operator*=() [1/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 & SA::Mat3< T, major >::operator*= ( const Mat3< T, major > & _rhs)
noexcept

Multiply matrices.

Parameters
[in]_rhsMatrix to multiply to.
Returns
self matrix result.

◆ operator*=() [2/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
template<typename TIn >
Mat3 & SA::Mat3< T, major >::operator*= ( TIn _scale)
noexcept

Scale each matrix component by _scale.

Template Parameters
TInType of the input scale.
Parameters
[in]_scaleScale value to apply on all components.
Returns
self matrix scaled.

◆ operator+()

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 SA::Mat3< T, major >::operator+ ( const Mat3< T, major > & _rhs) const
noexcept

Add term by term matrix values.

Parameters
[in]_rhsMatrix to add.
Returns
new matrix result.

◆ operator+=()

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 & SA::Mat3< T, major >::operator+= ( const Mat3< T, major > & _rhs)
noexcept

Add term by term matrix values.

Parameters
[in]_rhsMatrix to add.
Returns
self matrix result.

◆ operator-() [1/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
constexpr Mat3 SA::Mat3< T, major >::operator- ( ) const
constexprnoexcept

Getter of the opposite signed matrix.

Returns
new opposite signed matrix.

◆ operator-() [2/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 SA::Mat3< T, major >::operator- ( const Mat3< T, major > & _rhs) const
noexcept

Subtract term by term matrix values.

Parameters
[in]_rhsMatrix to substract.
Returns
new matrix result.

◆ operator-=()

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 & SA::Mat3< T, major >::operator-= ( const Mat3< T, major > & _rhs)
noexcept

Subtract term by term matrix values.

Parameters
[in]_rhsMatrix to substract.
Returns
self matrix result.

◆ operator/() [1/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 SA::Mat3< T, major >::operator/ ( const Mat3< T, major > & _rhs) const

Inverse multiply matrices.

Parameters
[in]_rhsMatrix to inverse multiply to.
Returns
new matrix result.

◆ operator/() [2/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
template<typename TIn >
Mat3 SA::Mat3< T, major >::operator/ ( TIn _scale) const

Inverse Scale each matrix component by _scale.

Template Parameters
TInType of the input scale.
Parameters
[in]_scaleInverse scale value to apply on all components.
Returns
new matrix inverse-scaled.

◆ operator/=() [1/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 & SA::Mat3< T, major >::operator/= ( const Mat3< T, major > & _rhs)

Inverse multiply matrices.

Parameters
[in]_rhsMatrix to inverse multiply to.
Returns
self matrix result.

◆ operator/=() [2/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
template<typename TIn >
Mat3 & SA::Mat3< T, major >::operator/= ( TIn _scale)

Inverse Scale each matrix component by _scale.

Template Parameters
TInType of the input scale.
Parameters
[in]_scaleInverse scale value to apply on all components.
Returns
self matrix inverse-scaled.

◆ operator=()

template<typename T , MatrixMajor major = MatrixMajor::Default>
template<typename TIn , MatrixMajor majorIn>
Mat3 & SA::Mat3< T, major >::operator= ( const Mat3< TIn, majorIn > _rhs)
noexcept

Assignment operator from another Mat3 type.

Template Parameters
TInType of the input Mat3.
majorInMajor of the input Mat3.
Parameters
[in]_rhsMat3 to assign from.

◆ operator==()

template<typename T , MatrixMajor major = MatrixMajor::Default>
constexpr bool SA::Mat3< T, major >::operator== ( const Mat3< T, major > & _rhs) const
constexprnoexcept

Compare 2 matrix equality.

Parameters
[in]_rhsOther matrix to compare to.
Returns
Whether this and _rhs are equal.

◆ operator[]() [1/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
T & SA::Mat3< T, major >::operator[] ( uint32_t _index)

Access operator by index.

Parameters
[in]_indexIndex to access.
Returns
T value at index.

◆ operator[]() [2/2]

template<typename T , MatrixMajor major = MatrixMajor::Default>
const T & SA::Mat3< T, major >::operator[] ( uint32_t _index) const

Const Access operator by index.

Parameters
[in]_indexIndex to access.
Returns
T value at index.

◆ Transpose()

template<typename T , MatrixMajor major = MatrixMajor::Default>
Mat3 & SA::Mat3< T, major >::Transpose ( )
noexcept

Transpose this matrix.

Returns
self transposed matrix.

Member Data Documentation

◆ Identity

template<typename T , MatrixMajor major = MatrixMajor::Default>
const Mat3 SA::Mat3< T, major >::Identity
static

Identity Mat3 constant.

{1, 0, 0} {0, 1, 0} {0, 0, 1}

◆ Zero

template<typename T , MatrixMajor major = MatrixMajor::Default>
const Mat3 SA::Mat3< T, major >::Zero
static

Zero Mat3 constant.

{0, 0, 0} {0, 0, 0} {0, 0, 0}


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