My Project
Loading...
Searching...
No Matches
Maths::Mat4< T > Class Template Reference

4x4 Matrix class template for 3D transformations Supports translation, rotation, scaling, multiplication, inversion, and more More...

#include <MMatrix4.hpp>

Public Member Functions

 Mat4 ()
 Default constructor (uninitialized matrix).
 Mat4 (T u, T d, T t, T q, T c, T si, T se, T h, T n, T di, T on, T dou, T tre, T qua, T qui, T sei)
 Constructor with 16 individual elements (row-major order).
 ~Mat4 ()=default
Mat4 Rotation4x4 (T angleX, T angleY, T angleZ)
 Compute rotation matrix from Euler angles (degrees).
std::array< T, 16 > Transpose4x4 (const Mat4 &mat)
 Transpose the given 4x4 matrix.
std::array< T, 16 > Inverse4x4 () const
 Compute inverse of this 4x4 matrix.
Maths::Vec3< T > LossyScale4x4 () const
 Extract approximate scale from matrix.
bool isIdentity4x4 () const
 Check if matrix is identity.
Det4x4 () const
 Compute determinant of the 4x4 matrix.
T & at (int r, int c)
 Access matrix element at row r, column c.
Maths::Vec3< T > MultiplyPoint3x4_4x4 (const Vec3< T > &vector) const
 Multiply a 3D point (Vec3) by 4x4 matrix.
Maths::Vec3< T > MultiplyVector4x4 (const Maths::Vec3< T > &vector) const
 Multiply a vector (direction) by 4x4 matrix.
Maths::Vec3< T > MultiplyPoint4x4 (const Maths::Vec3< T > &vector) const
 Multiply a point (Vec3) in homogeneous coordinates by 4x4 matrix.
Maths::Vec3< T > GetPosition4x4 () const
 Extract position vector from matrix.
Mat4 SetTRS (const Vec3< T > &translation, const Vec3< T > &rotationEulerDeg, const Vec3< T > &scale)
 Set matrix using Translation, Rotation (Euler deg), Scale.
Mat4 MultiplyMat4x4 (const Mat4 &A, const Mat4 &B) const
 Multiply two 4x4 matrices.
void SetColumn4x4 (T columnNumber, T number1, T number2, T number3, T number4)
 Set a specific column with 4 values.
void SetRow4x4 (T rowNumber, T number1, T number2, T number3, T number4)
 Set a specific row with 4 values.
void GetColumn4x4 (T column)
 Get a column (TODO: fix signature, currently just placeholder).
void GetRow4x4 (T row)
 Get a row (TODO: fix signature, currently just placeholder).
bool ValidTRS () const
 Check if this matrix is a valid TRS (Translation, Rotation, Scale) matrix.
std::string toString4x4 () const
 Convert matrix to string (for debugging).
Mat4 operator* (const Mat4 &other) const
 Matrix multiplication operator.

Static Public Member Functions

static Mat4 Identity ()
 Returns identity matrix (no transformation).
static Mat4 Zero ()
 Returns zero matrix.
static Mat4 TRS (const Maths::Vec3< T > &position, const Maths::Vec3< T > &rotationEuler, const Maths::Vec3< T > &scale)
static Mat4 LookAt4x4 (const Maths::Vec3< T > &from, const Maths::Vec3< T > &to, const Maths::Vec3< T > &up)
static Mat4 Ortho4x4 (T left, T right, T bottom, T top, T zNear, T zFar)
static Mat4 Perspective4x4 (T fovY, T aspect, T nearP, T farP)
static Mat4 TranslateVec4x4 (const Maths::Vec3< T > &t)
static Mat4 Rotate4x4 (const Maths::Quat< T > &q)
static Mat4 ScaleVec4x4 (const Maths::Vec3< T > &s)
static Mat4 Translate4x4 (T tx, T ty, T tz)
static Mat4 Scale4x4 (T sx, T sy, T sz)

Public Attributes

det
std::array< T, 16 > tabMat
float deg2rad = 3.14159265f / 180.f

Detailed Description

template<typename T = float>
class Maths::Mat4< T >

4x4 Matrix class template for 3D transformations Supports translation, rotation, scaling, multiplication, inversion, and more

Constructor & Destructor Documentation

◆ Mat4() [1/2]

template<typename T = float>
Maths::Mat4< T >::Mat4 ( )

Default constructor (uninitialized matrix).

◆ Mat4() [2/2]

template<typename T = float>
Maths::Mat4< T >::Mat4 ( T u,
T d,
T t,
T q,
T c,
T si,
T se,
T h,
T n,
T di,
T on,
T dou,
T tre,
T qua,
T qui,
T sei )

Constructor with 16 individual elements (row-major order).

◆ ~Mat4()

template<typename T = float>
Maths::Mat4< T >::~Mat4 ( )
default

Member Function Documentation

◆ at()

template<typename T = float>
T & Maths::Mat4< T >::at ( int r,
int c )

Access matrix element at row r, column c.

◆ Det4x4()

template<typename T = float>
T Maths::Mat4< T >::Det4x4 ( ) const

Compute determinant of the 4x4 matrix.

◆ GetColumn4x4()

template<typename T = float>
void Maths::Mat4< T >::GetColumn4x4 ( T column)

Get a column (TODO: fix signature, currently just placeholder).

◆ GetPosition4x4()

template<typename T = float>
Maths::Vec3< T > Maths::Mat4< T >::GetPosition4x4 ( ) const

Extract position vector from matrix.

◆ GetRow4x4()

template<typename T = float>
void Maths::Mat4< T >::GetRow4x4 ( T row)

Get a row (TODO: fix signature, currently just placeholder).

◆ Identity()

template<typename T = float>
Mat4 Maths::Mat4< T >::Identity ( )
static

Returns identity matrix (no transformation).

◆ Inverse4x4()

template<typename T = float>
std::array< T, 16 > Maths::Mat4< T >::Inverse4x4 ( ) const

Compute inverse of this 4x4 matrix.

◆ isIdentity4x4()

template<typename T = float>
bool Maths::Mat4< T >::isIdentity4x4 ( ) const

Check if matrix is identity.

◆ LookAt4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::LookAt4x4 ( const Maths::Vec3< T > & from,
const Maths::Vec3< T > & to,
const Maths::Vec3< T > & up )
static

◆ LossyScale4x4()

template<typename T = float>
Maths::Vec3< T > Maths::Mat4< T >::LossyScale4x4 ( ) const

Extract approximate scale from matrix.

◆ MultiplyMat4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::MultiplyMat4x4 ( const Mat4< T > & A,
const Mat4< T > & B ) const

Multiply two 4x4 matrices.

◆ MultiplyPoint3x4_4x4()

template<typename T = float>
Maths::Vec3< T > Maths::Mat4< T >::MultiplyPoint3x4_4x4 ( const Vec3< T > & vector) const

Multiply a 3D point (Vec3) by 4x4 matrix.

◆ MultiplyPoint4x4()

template<typename T = float>
Maths::Vec3< T > Maths::Mat4< T >::MultiplyPoint4x4 ( const Maths::Vec3< T > & vector) const

Multiply a point (Vec3) in homogeneous coordinates by 4x4 matrix.

◆ MultiplyVector4x4()

template<typename T = float>
Maths::Vec3< T > Maths::Mat4< T >::MultiplyVector4x4 ( const Maths::Vec3< T > & vector) const

Multiply a vector (direction) by 4x4 matrix.

◆ operator*()

template<typename T = float>
Mat4 Maths::Mat4< T >::operator* ( const Mat4< T > & other) const

Matrix multiplication operator.

OPERATORS //////////

◆ Ortho4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::Ortho4x4 ( T left,
T right,
T bottom,
T top,
T zNear,
T zFar )
static

◆ Perspective4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::Perspective4x4 ( T fovY,
T aspect,
T nearP,
T farP )
static

◆ Rotate4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::Rotate4x4 ( const Maths::Quat< T > & q)
static

◆ Rotation4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::Rotation4x4 ( T angleX,
T angleY,
T angleZ )

Compute rotation matrix from Euler angles (degrees).

◆ Scale4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::Scale4x4 ( T sx,
T sy,
T sz )
static

◆ ScaleVec4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::ScaleVec4x4 ( const Maths::Vec3< T > & s)
static

◆ SetColumn4x4()

template<typename T = float>
void Maths::Mat4< T >::SetColumn4x4 ( T columnNumber,
T number1,
T number2,
T number3,
T number4 )

Set a specific column with 4 values.

◆ SetRow4x4()

template<typename T = float>
void Maths::Mat4< T >::SetRow4x4 ( T rowNumber,
T number1,
T number2,
T number3,
T number4 )

Set a specific row with 4 values.

◆ SetTRS()

template<typename T = float>
Mat4 Maths::Mat4< T >::SetTRS ( const Vec3< T > & translation,
const Vec3< T > & rotationEulerDeg,
const Vec3< T > & scale )

Set matrix using Translation, Rotation (Euler deg), Scale.

◆ toString4x4()

template<typename T = float>
std::string Maths::Mat4< T >::toString4x4 ( ) const

Convert matrix to string (for debugging).

◆ Translate4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::Translate4x4 ( T tx,
T ty,
T tz )
static

◆ TranslateVec4x4()

template<typename T = float>
Mat4 Maths::Mat4< T >::TranslateVec4x4 ( const Maths::Vec3< T > & t)
static

◆ Transpose4x4()

template<typename T = float>
std::array< T, 16 > Maths::Mat4< T >::Transpose4x4 ( const Mat4< T > & mat)

Transpose the given 4x4 matrix.

◆ TRS()

template<typename T = float>
Mat4 Maths::Mat4< T >::TRS ( const Maths::Vec3< T > & position,
const Maths::Vec3< T > & rotationEuler,
const Maths::Vec3< T > & scale )
static

◆ ValidTRS()

template<typename T = float>
bool Maths::Mat4< T >::ValidTRS ( ) const

Check if this matrix is a valid TRS (Translation, Rotation, Scale) matrix.

◆ Zero()

template<typename T = float>
Mat4 Maths::Mat4< T >::Zero ( )
static

Returns zero matrix.

Member Data Documentation

◆ deg2rad

template<typename T = float>
float Maths::Mat4< T >::deg2rad = 3.14159265f / 180.f

◆ det

template<typename T = float>
T Maths::Mat4< T >::det

◆ tabMat

template<typename T = float>
std::array<T, 16> Maths::Mat4< T >::tabMat

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