Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
Mat44 Class Reference

Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix. More...

#include <Mat44.h>

Public Types

using Type = Vec4::Type
 
using ArgType = Mat44Arg
 

Public Member Functions

 Mat44 ()=default
 Constructor.
 
JPH_INLINE Mat44 (Vec4Arg inC1, Vec4Arg inC2, Vec4Arg inC3, Vec4Arg inC4)
 
JPH_INLINE Mat44 (Vec4Arg inC1, Vec4Arg inC2, Vec4Arg inC3, Vec3Arg inC4)
 
 Mat44 (const Mat44 &inM2)=default
 
Mat44operator= (const Mat44 &inM2)=default
 
JPH_INLINE Mat44 (Type inC1, Type inC2, Type inC3, Type inC4)
 
JPH_INLINE float operator() (uint inRow, uint inColumn) const
 Get float component by element index.
 
JPH_INLINE float & operator() (uint inRow, uint inColumn)
 
JPH_INLINE bool operator== (Mat44Arg inM2) const
 Comparison.
 
JPH_INLINE bool operator!= (Mat44Arg inM2) const
 
JPH_INLINE bool IsClose (Mat44Arg inM2, float inMaxDistSq=1.0e-12f) const
 Test if two matrices are close.
 
JPH_INLINE Mat44 operator* (Mat44Arg inM) const
 Multiply matrix by matrix.
 
JPH_INLINE Vec3 operator* (Vec3Arg inV) const
 Multiply vector by matrix.
 
JPH_INLINE Vec4 operator* (Vec4Arg inV) const
 
JPH_INLINE Vec3 Multiply3x3 (Vec3Arg inV) const
 Multiply vector by only 3x3 part of the matrix.
 
JPH_INLINE Vec3 Multiply3x3Transposed (Vec3Arg inV) const
 Multiply vector by only 3x3 part of the transpose of the matrix ( \(result = this^T \: inV\))
 
JPH_INLINE Mat44 Multiply3x3 (Mat44Arg inM) const
 Multiply 3x3 matrix by 3x3 matrix.
 
JPH_INLINE Mat44 Multiply3x3LeftTransposed (Mat44Arg inM) const
 Multiply transpose of 3x3 matrix by 3x3 matrix ( \(result = this^T \: inM\))
 
JPH_INLINE Mat44 Multiply3x3RightTransposed (Mat44Arg inM) const
 Multiply 3x3 matrix by the transpose of a 3x3 matrix ( \(result = this \: inM^T\))
 
JPH_INLINE Mat44 operator* (float inV) const
 Multiply matrix with float.
 
JPH_INLINE Mat44operator*= (float inV)
 Multiply matrix with float.
 
JPH_INLINE Mat44 operator+ (Mat44Arg inM) const
 Per element addition of matrix.
 
JPH_INLINE Mat44 operator- () const
 Negate.
 
JPH_INLINE Mat44 operator- (Mat44Arg inM) const
 Per element subtraction of matrix.
 
JPH_INLINE Mat44operator+= (Mat44Arg inM)
 Per element addition of matrix.
 
JPH_INLINE Vec3 GetAxisX () const
 Access to the columns.
 
JPH_INLINE void SetAxisX (Vec3Arg inV)
 
JPH_INLINE Vec3 GetAxisY () const
 
JPH_INLINE void SetAxisY (Vec3Arg inV)
 
JPH_INLINE Vec3 GetAxisZ () const
 
JPH_INLINE void SetAxisZ (Vec3Arg inV)
 
JPH_INLINE Vec3 GetTranslation () const
 
JPH_INLINE void SetTranslation (Vec3Arg inV)
 
JPH_INLINE Vec3 GetDiagonal3 () const
 
JPH_INLINE void SetDiagonal3 (Vec3Arg inV)
 
JPH_INLINE Vec4 GetDiagonal4 () const
 
JPH_INLINE void SetDiagonal4 (Vec4Arg inV)
 
JPH_INLINE Vec3 GetColumn3 (uint inCol) const
 
JPH_INLINE void SetColumn3 (uint inCol, Vec3Arg inV)
 
JPH_INLINE Vec4 GetColumn4 (uint inCol) const
 
JPH_INLINE void SetColumn4 (uint inCol, Vec4Arg inV)
 
JPH_INLINE void StoreFloat4x4 (Float4 *outV) const
 Store matrix to memory.
 
JPH_INLINE Mat44 Transposed () const
 Transpose matrix.
 
JPH_INLINE Mat44 Transposed3x3 () const
 Transpose 3x3 subpart of matrix.
 
JPH_INLINE Mat44 Inversed () const
 Inverse 4x4 matrix.
 
JPH_INLINE Mat44 InversedRotationTranslation () const
 Inverse 4x4 matrix when it only contains rotation and translation.
 
JPH_INLINE float GetDeterminant3x3 () const
 Get the determinant of a 3x3 matrix.
 
JPH_INLINE Mat44 Adjointed3x3 () const
 Get the adjoint of a 3x3 matrix.
 
JPH_INLINE Mat44 Inversed3x3 () const
 Inverse 3x3 matrix.
 
JPH_INLINE bool SetInversed3x3 (Mat44Arg inM)
 *this = inM.Inversed3x3(), returns false if the matrix is singular in which case *this is unchanged
 
JPH_INLINE Mat44 GetRotation () const
 Get rotation part only (note: retains the first 3 values from the bottom row)
 
JPH_INLINE Mat44 GetRotationSafe () const
 Get rotation part only (note: also clears the bottom row)
 
JPH_INLINE void SetRotation (Mat44Arg inRotation)
 Updates the rotation part of this matrix (the first 3 columns)
 
JPH_INLINE Quat GetQuaternion () const
 Convert to quaternion.
 
JPH_INLINE Mat44 GetDirectionPreservingMatrix () const
 Get matrix that transforms a direction with the same transform as this matrix (length is not preserved)
 
JPH_INLINE Mat44 PreTranslated (Vec3Arg inTranslation) const
 Pre multiply by translation matrix: result = this * Mat44::sTranslation(inTranslation)
 
JPH_INLINE Mat44 PostTranslated (Vec3Arg inTranslation) const
 Post multiply by translation matrix: result = Mat44::sTranslation(inTranslation) * this (i.e. add inTranslation to the 4-th column)
 
JPH_INLINE Mat44 PreScaled (Vec3Arg inScale) const
 Scale a matrix: result = this * Mat44::sScale(inScale)
 
JPH_INLINE Mat44 PostScaled (Vec3Arg inScale) const
 Scale a matrix: result = Mat44::sScale(inScale) * this.
 
JPH_INLINE Mat44 Decompose (Vec3 &outScale) const
 
JPH_INLINE Mat44 ToMat44 () const
 In single precision mode just return the matrix itself.
 

Static Public Member Functions

static JPH_INLINE Mat44 sZero ()
 Zero matrix.
 
static JPH_INLINE Mat44 sIdentity ()
 Identity matrix.
 
static JPH_INLINE Mat44 sNaN ()
 Matrix filled with NaN's.
 
static JPH_INLINE Mat44 sLoadFloat4x4 (const Float4 *inV)
 Load 16 floats from memory.
 
static JPH_INLINE Mat44 sLoadFloat4x4Aligned (const Float4 *inV)
 Load 16 floats from memory, 16 bytes aligned.
 
static JPH_INLINE Mat44 sRotationX (float inX)
 Rotate around X, Y or Z axis (angle in radians)
 
static JPH_INLINE Mat44 sRotationY (float inY)
 
static JPH_INLINE Mat44 sRotationZ (float inZ)
 
static JPH_INLINE Mat44 sRotation (Vec3Arg inAxis, float inAngle)
 Rotate around arbitrary axis.
 
static JPH_INLINE Mat44 sRotation (QuatArg inQuat)
 Rotate from quaternion.
 
static JPH_INLINE Mat44 sTranslation (Vec3Arg inV)
 Get matrix that translates.
 
static JPH_INLINE Mat44 sRotationTranslation (QuatArg inR, Vec3Arg inT)
 Get matrix that rotates and translates.
 
static JPH_INLINE Mat44 sInverseRotationTranslation (QuatArg inR, Vec3Arg inT)
 Get inverse matrix of sRotationTranslation.
 
static JPH_INLINE Mat44 sScale (float inScale)
 Get matrix that scales uniformly.
 
static JPH_INLINE Mat44 sScale (Vec3Arg inV)
 Get matrix that scales (produces a matrix with (inV, 1) on its diagonal)
 
static JPH_INLINE Mat44 sOuterProduct (Vec3Arg inV1, Vec3Arg inV2)
 Get outer product of inV and inV2 (equivalent to \(inV1 \otimes inV2\))
 
static JPH_INLINE Mat44 sCrossProduct (Vec3Arg inV)
 Get matrix that represents a cross product \(A \times B = \text{sCrossProduct}(A) \: B\).
 
static JPH_INLINE Mat44 sQuatLeftMultiply (QuatArg inQ)
 Returns matrix ML so that \(ML(q) \: p = q \: p\) (where p and q are quaternions)
 
static JPH_INLINE Mat44 sQuatRightMultiply (QuatArg inQ)
 Returns matrix MR so that \(MR(q) \: p = p \: q\) (where p and q are quaternions)
 
static JPH_INLINE Mat44 sLookAt (Vec3Arg inPos, Vec3Arg inTarget, Vec3Arg inUp)
 
static JPH_INLINE Mat44 sPerspective (float inFovY, float inAspect, float inNear, float inFar)
 Returns a right-handed perspective projection matrix.
 

Friends

JPH_INLINE Mat44 operator* (float inV, Mat44Arg inM)
 
ostream & operator<< (ostream &inStream, Mat44Arg inM)
 To String.
 

Detailed Description

Holds a 4x4 matrix of floats, but supports also operations on the 3x3 upper left part of the matrix.

Member Typedef Documentation

◆ ArgType

◆ Type

Constructor & Destructor Documentation

◆ Mat44() [1/5]

Mat44::Mat44 ( )
default

Constructor.

Intentionally not initialized for performance reasons

◆ Mat44() [2/5]

Mat44::Mat44 ( Vec4Arg  inC1,
Vec4Arg  inC2,
Vec4Arg  inC3,
Vec4Arg  inC4 
)

◆ Mat44() [3/5]

Mat44::Mat44 ( Vec4Arg  inC1,
Vec4Arg  inC2,
Vec4Arg  inC3,
Vec3Arg  inC4 
)

◆ Mat44() [4/5]

Mat44::Mat44 ( const Mat44 inM2)
default

◆ Mat44() [5/5]

Mat44::Mat44 ( Type  inC1,
Type  inC2,
Type  inC3,
Type  inC4 
)

Member Function Documentation

◆ Adjointed3x3()

Mat44 Mat44::Adjointed3x3 ( ) const

Get the adjoint of a 3x3 matrix.

◆ Decompose()

Mat44 Mat44::Decompose ( Vec3 outScale) const

Decompose a matrix into a rotation & translation part and into a scale part so that: this = return_value * Mat44::sScale(outScale). This equation only holds when the matrix is orthogonal, if it is not the returned matrix will be made orthogonal using the modified Gram-Schmidt algorithm (see: https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process)

◆ GetAxisX()

JPH_INLINE Vec3 Mat44::GetAxisX ( ) const
inline

Access to the columns.

◆ GetAxisY()

JPH_INLINE Vec3 Mat44::GetAxisY ( ) const
inline

◆ GetAxisZ()

JPH_INLINE Vec3 Mat44::GetAxisZ ( ) const
inline

◆ GetColumn3()

JPH_INLINE Vec3 Mat44::GetColumn3 ( uint  inCol) const
inline

◆ GetColumn4()

JPH_INLINE Vec4 Mat44::GetColumn4 ( uint  inCol) const
inline

◆ GetDeterminant3x3()

float Mat44::GetDeterminant3x3 ( ) const

Get the determinant of a 3x3 matrix.

◆ GetDiagonal3()

JPH_INLINE Vec3 Mat44::GetDiagonal3 ( ) const
inline

◆ GetDiagonal4()

JPH_INLINE Vec4 Mat44::GetDiagonal4 ( ) const
inline

◆ GetDirectionPreservingMatrix()

JPH_INLINE Mat44 Mat44::GetDirectionPreservingMatrix ( ) const
inline

Get matrix that transforms a direction with the same transform as this matrix (length is not preserved)

◆ GetQuaternion()

Quat Mat44::GetQuaternion ( ) const

Convert to quaternion.

◆ GetRotation()

Mat44 Mat44::GetRotation ( ) const

Get rotation part only (note: retains the first 3 values from the bottom row)

◆ GetRotationSafe()

Mat44 Mat44::GetRotationSafe ( ) const

Get rotation part only (note: also clears the bottom row)

◆ GetTranslation()

JPH_INLINE Vec3 Mat44::GetTranslation ( ) const
inline

◆ Inversed()

Mat44 Mat44::Inversed ( ) const

Inverse 4x4 matrix.

◆ Inversed3x3()

Mat44 Mat44::Inversed3x3 ( ) const

Inverse 3x3 matrix.

◆ InversedRotationTranslation()

Mat44 Mat44::InversedRotationTranslation ( ) const

Inverse 4x4 matrix when it only contains rotation and translation.

◆ IsClose()

bool Mat44::IsClose ( Mat44Arg  inM2,
float  inMaxDistSq = 1.0e-12f 
) const

Test if two matrices are close.

◆ Multiply3x3() [1/2]

Mat44 Mat44::Multiply3x3 ( Mat44Arg  inM) const

Multiply 3x3 matrix by 3x3 matrix.

◆ Multiply3x3() [2/2]

Vec3 Mat44::Multiply3x3 ( Vec3Arg  inV) const

Multiply vector by only 3x3 part of the matrix.

◆ Multiply3x3LeftTransposed()

Mat44 Mat44::Multiply3x3LeftTransposed ( Mat44Arg  inM) const

Multiply transpose of 3x3 matrix by 3x3 matrix ( \(result = this^T \: inM\))

◆ Multiply3x3RightTransposed()

Mat44 Mat44::Multiply3x3RightTransposed ( Mat44Arg  inM) const

Multiply 3x3 matrix by the transpose of a 3x3 matrix ( \(result = this \: inM^T\))

◆ Multiply3x3Transposed()

Vec3 Mat44::Multiply3x3Transposed ( Vec3Arg  inV) const

Multiply vector by only 3x3 part of the transpose of the matrix ( \(result = this^T \: inV\))

◆ operator!=()

JPH_INLINE bool Mat44::operator!= ( Mat44Arg  inM2) const
inline

◆ operator()() [1/2]

JPH_INLINE float & Mat44::operator() ( uint  inRow,
uint  inColumn 
)
inline

◆ operator()() [2/2]

JPH_INLINE float Mat44::operator() ( uint  inRow,
uint  inColumn 
) const
inline

Get float component by element index.

◆ operator*() [1/4]

Mat44 Mat44::operator* ( float  inV) const

Multiply matrix with float.

◆ operator*() [2/4]

Mat44 Mat44::operator* ( Mat44Arg  inM) const

Multiply matrix by matrix.

◆ operator*() [3/4]

Vec3 Mat44::operator* ( Vec3Arg  inV) const

Multiply vector by matrix.

◆ operator*() [4/4]

Vec4 Mat44::operator* ( Vec4Arg  inV) const

◆ operator*=()

Mat44 & Mat44::operator*= ( float  inV)

Multiply matrix with float.

◆ operator+()

Mat44 Mat44::operator+ ( Mat44Arg  inM) const

Per element addition of matrix.

◆ operator+=()

Mat44 & Mat44::operator+= ( Mat44Arg  inM)

Per element addition of matrix.

◆ operator-() [1/2]

Mat44 Mat44::operator- ( ) const

Negate.

◆ operator-() [2/2]

Mat44 Mat44::operator- ( Mat44Arg  inM) const

Per element subtraction of matrix.

◆ operator=()

Mat44 & Mat44::operator= ( const Mat44 inM2)
default

◆ operator==()

bool Mat44::operator== ( Mat44Arg  inM2) const

Comparison.

◆ PostScaled()

Mat44 Mat44::PostScaled ( Vec3Arg  inScale) const

Scale a matrix: result = Mat44::sScale(inScale) * this.

◆ PostTranslated()

Mat44 Mat44::PostTranslated ( Vec3Arg  inTranslation) const

Post multiply by translation matrix: result = Mat44::sTranslation(inTranslation) * this (i.e. add inTranslation to the 4-th column)

◆ PreScaled()

Mat44 Mat44::PreScaled ( Vec3Arg  inScale) const

Scale a matrix: result = this * Mat44::sScale(inScale)

◆ PreTranslated()

Mat44 Mat44::PreTranslated ( Vec3Arg  inTranslation) const

Pre multiply by translation matrix: result = this * Mat44::sTranslation(inTranslation)

◆ sCrossProduct()

Mat44 Mat44::sCrossProduct ( Vec3Arg  inV)
static

Get matrix that represents a cross product \(A \times B = \text{sCrossProduct}(A) \: B\).

◆ SetAxisX()

JPH_INLINE void Mat44::SetAxisX ( Vec3Arg  inV)
inline

◆ SetAxisY()

JPH_INLINE void Mat44::SetAxisY ( Vec3Arg  inV)
inline

◆ SetAxisZ()

JPH_INLINE void Mat44::SetAxisZ ( Vec3Arg  inV)
inline

◆ SetColumn3()

JPH_INLINE void Mat44::SetColumn3 ( uint  inCol,
Vec3Arg  inV 
)
inline

◆ SetColumn4()

JPH_INLINE void Mat44::SetColumn4 ( uint  inCol,
Vec4Arg  inV 
)
inline

◆ SetDiagonal3()

JPH_INLINE void Mat44::SetDiagonal3 ( Vec3Arg  inV)
inline

◆ SetDiagonal4()

JPH_INLINE void Mat44::SetDiagonal4 ( Vec4Arg  inV)
inline

◆ SetInversed3x3()

bool Mat44::SetInversed3x3 ( Mat44Arg  inM)

*this = inM.Inversed3x3(), returns false if the matrix is singular in which case *this is unchanged

◆ SetRotation()

void Mat44::SetRotation ( Mat44Arg  inRotation)

Updates the rotation part of this matrix (the first 3 columns)

◆ SetTranslation()

JPH_INLINE void Mat44::SetTranslation ( Vec3Arg  inV)
inline

◆ sIdentity()

Mat44 Mat44::sIdentity ( )
static

Identity matrix.

◆ sInverseRotationTranslation()

Mat44 Mat44::sInverseRotationTranslation ( QuatArg  inR,
Vec3Arg  inT 
)
static

Get inverse matrix of sRotationTranslation.

◆ sLoadFloat4x4()

Mat44 Mat44::sLoadFloat4x4 ( const Float4 inV)
static

Load 16 floats from memory.

◆ sLoadFloat4x4Aligned()

Mat44 Mat44::sLoadFloat4x4Aligned ( const Float4 inV)
static

Load 16 floats from memory, 16 bytes aligned.

◆ sLookAt()

Mat44 Mat44::sLookAt ( Vec3Arg  inPos,
Vec3Arg  inTarget,
Vec3Arg  inUp 
)
static

Returns a look at matrix that transforms from world space to view space

Parameters
inPosPosition of the camera
inTargetTarget of the camera
inUpUp vector

◆ sNaN()

Mat44 Mat44::sNaN ( )
static

Matrix filled with NaN's.

◆ sOuterProduct()

Mat44 Mat44::sOuterProduct ( Vec3Arg  inV1,
Vec3Arg  inV2 
)
static

Get outer product of inV and inV2 (equivalent to \(inV1 \otimes inV2\))

◆ sPerspective()

Mat44 Mat44::sPerspective ( float  inFovY,
float  inAspect,
float  inNear,
float  inFar 
)
static

Returns a right-handed perspective projection matrix.

◆ sQuatLeftMultiply()

Mat44 Mat44::sQuatLeftMultiply ( QuatArg  inQ)
static

Returns matrix ML so that \(ML(q) \: p = q \: p\) (where p and q are quaternions)

◆ sQuatRightMultiply()

Mat44 Mat44::sQuatRightMultiply ( QuatArg  inQ)
static

Returns matrix MR so that \(MR(q) \: p = p \: q\) (where p and q are quaternions)

◆ sRotation() [1/2]

Mat44 Mat44::sRotation ( QuatArg  inQuat)
static

Rotate from quaternion.

◆ sRotation() [2/2]

Mat44 Mat44::sRotation ( Vec3Arg  inAxis,
float  inAngle 
)
static

Rotate around arbitrary axis.

◆ sRotationTranslation()

Mat44 Mat44::sRotationTranslation ( QuatArg  inR,
Vec3Arg  inT 
)
static

Get matrix that rotates and translates.

◆ sRotationX()

Mat44 Mat44::sRotationX ( float  inX)
static

Rotate around X, Y or Z axis (angle in radians)

◆ sRotationY()

Mat44 Mat44::sRotationY ( float  inY)
static

◆ sRotationZ()

Mat44 Mat44::sRotationZ ( float  inZ)
static

◆ sScale() [1/2]

Mat44 Mat44::sScale ( float  inScale)
static

Get matrix that scales uniformly.

◆ sScale() [2/2]

Mat44 Mat44::sScale ( Vec3Arg  inV)
static

Get matrix that scales (produces a matrix with (inV, 1) on its diagonal)

◆ StoreFloat4x4()

void Mat44::StoreFloat4x4 ( Float4 outV) const

Store matrix to memory.

◆ sTranslation()

Mat44 Mat44::sTranslation ( Vec3Arg  inV)
static

Get matrix that translates.

◆ sZero()

Mat44 Mat44::sZero ( )
static

Zero matrix.

◆ ToMat44()

JPH_INLINE Mat44 Mat44::ToMat44 ( ) const
inline

In single precision mode just return the matrix itself.

◆ Transposed()

Mat44 Mat44::Transposed ( ) const

Transpose matrix.

◆ Transposed3x3()

Mat44 Mat44::Transposed3x3 ( ) const

Transpose 3x3 subpart of matrix.

Friends And Related Symbol Documentation

◆ operator*

JPH_INLINE Mat44 operator* ( float  inV,
Mat44Arg  inM 
)
friend

◆ operator<<

ostream & operator<< ( ostream &  inStream,
Mat44Arg  inM 
)
friend

To String.


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