Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cMatrix4x4f Class Reference

#include <cMatrix.h>

Inheritance diagram for GrayLib::cMatrix4x4f:
GrayLib::cMatrixT< DVALUEDEF_t, 4, 4 >

Public Types

typedef cMatrixT< DVALUEDEF_t, k_nDim, k_nDimSUPER_t
 
typedef cMatrix4x4f THIS_t
 
- Public Types inherited from GrayLib::cMatrixT< DVALUEDEF_t, 4, 4 >
typedef DVALUEDEF_t DVALUE_t
 

Public Member Functions

 cMatrix4x4f ()
 
 cMatrix4x4f (const SUPER_t &src)
 
 cMatrix4x4f (const DVALUE_t *pSrc)
 
 cMatrix4x4f (DVALUE_t n11, DVALUE_t n12=0, DVALUE_t n13=0, DVALUE_t n14=0, DVALUE_t n21=0, DVALUE_t n22=0, DVALUE_t n23=0, DVALUE_t n24=0, DVALUE_t n31=0, DVALUE_t n32=0, DVALUE_t n33=0, DVALUE_t n34=0, DVALUE_t n41=0, DVALUE_t n42=0, DVALUE_t n43=0, DVALUE_t n44=0)
 
const cVector3fGetAxis3 (AXIS_TYPE eAxis) const
 
const cVector4fGetAxis4 (int nRow) const
 
const cVector3fget_XAxis () const
 
const cVector3fget_YAxis () const
 
const cVector3fget_ZAxis () const
 
const cVector3fget_Translation () const
 
DVALUE_t get_Scaling1N () const
 
cVector3f get_ScalingN () const
 
cVector3f get_ScalingU () const
 
bool isIdentity () const
 
THIS_t get_Normalized () const
 
cQuaternionf get_RotationQ () const
 
DVALUE_t GetDeterminant () const
 
THIS_t GetTranspose () const
 
THIS_t GetInverse (DVALUE_t *pfDeterminant=nullptr) const
 
THIS_t operator- () const
 
THIS_t GetMul (const THIS_t &m2) const
 
THIS_t operator* (const THIS_t &m2) const
 
void Decompose (cVector3f &vScale, cQuaternionf &qRot, cVector3f &vTrans) const
 
void InitIdentity ()
 
void InitTranslation (DVALUE_t x, DVALUE_t y, DVALUE_t z)
 
void InitTranslation (const cVector3f &pt)
 
void InitScaling (DVALUE_t _x, DVALUE_t _y, DVALUE_t _z)
 
void InitScaling (const cVector3f &pt)
 
void InitScaling (DVALUE_t fScale)
 
void InitRotationQ (const cQuaternionf &q)
 
void InitRotationX (RADIANf_t fAngleX)
 
void InitRotationY (RADIANf_t fAngleY)
 
void InitRotationZ (RADIANf_t fAngleZ)
 
void InitRotationAxis (const cVector3f &vAxis, RADIANf_t fAngle)
 
void InitInverse (const THIS_t &m1, DVALUE_t *pfDeterminant=nullptr)
 
void InitTranspose (const THIS_t &m1)
 
void InitMul (const THIS_t &m1, const THIS_t &m2)
 
void InitPerspectiveFovLH (DVALUE_t fovy, DVALUE_t aspect, DVALUE_t zn, DVALUE_t zf)
 
void InitOrthoOffCenterLH (DVALUE_t l, DVALUE_t r, DVALUE_t b, DVALUE_t t, DVALUE_t zn, DVALUE_t zf)
 
void InitYawPitchRoll (RADIANf_t yaw, RADIANf_t pitch, RADIANf_t roll)
 
void InitReflect (const cPlanef &plane)
 
void InitLookAtLH (const cVector3f &vEye, const cVector3f &vAt, const cVector3f &vUp)
 
void InitTransformation (const cVector3f *pvScalingCenter=nullptr, const cQuaternionf *pqScalingRotation=nullptr, const cVector3f *pvScaling=nullptr, const cVector3f *pvRotationcenter=nullptr, const cQuaternionf *pqRotation=nullptr, const cVector3f *pvTranslation=nullptr)
 
void InitTransformation2D (const cVector2f *pvScalingCenter=nullptr, float fScalingRotation=0, const cVector2f *pvScaling=nullptr, const cVector2f *pvRotationCenter=nullptr, RADIANf_t fRotation=0, const cVector2f *pvTranslation=nullptr)
 
cVector3fref_XAxis ()
 
cVector3fref_YAxis ()
 
cVector3fref_ZAxis ()
 
cVector3fref_Translation ()
 
cVector3fRefAxis3 (AXIS_TYPE eAxis)
 
cVector4fRefAxis4 (int nRow)
 
void SetTranslation (DVALUE_t _x=0, DVALUE_t _y=0, DVALUE_t _z=0)
 
void SetScaling (DVALUE_t _x, DVALUE_t _y, DVALUE_t _z)
 
void put_Scaling1 (DVALUE_t fScale=0)
 
void SetScalingT (DVALUE_t _x, DVALUE_t _y, DVALUE_t _z)
 
void SetNormalized ()
 
void SetInvert (DVALUE_t *pfDeterminant=nullptr)
 
void SetTranspose ()
 
void SetMul (const THIS_t &m2)
 
const THIS_toperator*= (const THIS_t &m2)
 
 UNITTEST_FRIEND (cMatrix)
 
- Public Member Functions inherited from GrayLib::cMatrixT< DVALUEDEF_t, 4, 4 >
 cMatrixT () noexcept
 
 cMatrixT (const THIS_t &v) noexcept
 
 cMatrixT (const DVALUEDEF_t *pVals) noexcept
 
bool IsNear (const THIS_t &v2, DVALUEDEF_t fDist=(DVALUEDEF_t) k_FLT_MIN2) const
 
COMPARE_t Compare (const THIS_t &v2) const
 
bool operator== (const THIS_t &v2) const
 
bool operator!= (const THIS_t &v2) const
 
void InitMul (const cMatrixT< DVALUEDEF_t, _ROWS, _IDN > &m1, const cMatrixT< DVALUEDEF_t, _IDN, _COLS > &m2)
 
DVALUEDEF_tRefRow (int nRow)
 
const DVALUEDEF_tGetRow (int nRow) const
 
const DVALUEDEF_tGetRow (AXIS_TYPE eAxis) const
 
void SetRow (int nRow, const DVALUEDEF_t *p)
 
cVecT< DVALUEDEF_t, _COLS > & RefRowV (int nRow)
 
const cVecT< DVALUEDEF_t, _COLS > & GetRowV (int nRow) const
 
void SetRowV (int nRow, const cVecT< DVALUEDEF_t, _COLS > &v)
 
void CopyColTo (int nCol, DVALUEDEF_t *pV) const
 
void CopyColToV (int nCol, cVecT< DVALUEDEF_t, _ROWS > &v) const
 
cVecT< DVALUEDEF_t, _ROWS > GetColV (int nCol) const
 
void SetCol (int nCol, const DVALUEDEF_t *pV)
 
void SetColV (int nCol, const cVecT< DVALUEDEF_t, _ROWS > &v)
 

Static Public Attributes

static const int k_nDim = 4
 
static const THIS_t k_Identity
 
- Static Public Attributes inherited from GrayLib::cMatrixT< DVALUEDEF_t, 4, 4 >
static const int k_nRows
 
static const int k_nCols
 

Additional Inherited Members

- Public Attributes inherited from GrayLib::cMatrixT< DVALUEDEF_t, 4, 4 >
DVALUEDEF_t m_a [_ROWS *_COLS]
 
DVALUEDEF_t m [_ROWS][_COLS]
 
union {
   TYPE   m_a [_ROWS *_COLS]
 
   TYPE   m [_ROWS][_COLS]
 
}; 
 

Detailed Description

D3DXMATRIXA16 is 16 byte aligned for speed. D3DX_ALIGN16 XMFLOAT4X4 for better MMX,SSE access same as shader 'float4x4'

Member Typedef Documentation

◆ SUPER_t

◆ THIS_t

Constructor & Destructor Documentation

◆ cMatrix4x4f() [1/4]

GrayLib::cMatrix4x4f::cMatrix4x4f ( )
inline

ASSUME no/random/undefined init matrix data.

◆ cMatrix4x4f() [2/4]

GrayLib::cMatrix4x4f::cMatrix4x4f ( const SUPER_t src)
inline

◆ cMatrix4x4f() [3/4]

GrayLib::cMatrix4x4f::cMatrix4x4f ( const DVALUE_t pSrc)
inline

Array of values. ASSUME >= 16

◆ cMatrix4x4f() [4/4]

GrayLib::cMatrix4x4f::cMatrix4x4f ( DVALUE_t  n11,
DVALUE_t  n12 = 0,
DVALUE_t  n13 = 0,
DVALUE_t  n14 = 0,
DVALUE_t  n21 = 0,
DVALUE_t  n22 = 0,
DVALUE_t  n23 = 0,
DVALUE_t  n24 = 0,
DVALUE_t  n31 = 0,
DVALUE_t  n32 = 0,
DVALUE_t  n33 = 0,
DVALUE_t  n34 = 0,
DVALUE_t  n41 = 0,
DVALUE_t  n42 = 0,
DVALUE_t  n43 = 0,
DVALUE_t  n44 = 0 
)
inline

Member Function Documentation

◆ Decompose()

void GrayLib::cMatrix4x4f::Decompose ( cVector3f vScale,
cQuaternionf qRot,
cVector3f vTrans 
) const
inline

◆ get_Normalized()

THIS_t GrayLib::cMatrix4x4f::get_Normalized ( ) const
inline

Get the matrix normalized. remove the scaling info.

Note
This is weird !?

◆ get_RotationQ()

cQuaternionf GrayLib::cMatrix4x4f::get_RotationQ ( ) const
inline
Note
if the matrix is not normalized i can just normalize the quaternion when I'm done.

◆ get_Scaling1N()

DVALUE_t GrayLib::cMatrix4x4f::get_Scaling1N ( ) const
inline

unify the scale to be locked aspect ratio. Assumes a Identity type matrix

Note
is not valid if there is a rotation ! use get_ScalingU()

◆ get_ScalingN()

cVector3f GrayLib::cMatrix4x4f::get_ScalingN ( ) const
inline

Assumes a Identity type matrix

Note
is not valid if there is a rotation ! use get_ScalingU()

◆ get_ScalingU()

cVector3f GrayLib::cMatrix4x4f::get_ScalingU ( ) const
inline

get magnitudes for scaling portion of matrix. factors out any rotation.

◆ get_Translation()

const cVector3f& GrayLib::cMatrix4x4f::get_Translation ( ) const
inline

Only really useful for row-major matrices in a left-handed space. (Dx not OpenGL)

◆ get_XAxis()

const cVector3f& GrayLib::cMatrix4x4f::get_XAxis ( ) const
inline

GetRight() for D3D Assume axis are stored in DirectX style NOT OpenGL style (which is transposed)

◆ get_YAxis()

const cVector3f& GrayLib::cMatrix4x4f::get_YAxis ( ) const
inline

GetUp() for D3D

◆ get_ZAxis()

const cVector3f& GrayLib::cMatrix4x4f::get_ZAxis ( ) const
inline

GetForward() for D3D

◆ GetAxis3()

const cVector3f& GrayLib::cMatrix4x4f::GetAxis3 ( AXIS_TYPE  eAxis) const
inline

Only really useful for row-major matrices in a left-handed space. (Dx not OpenGL)

◆ GetAxis4()

const cVector4f& GrayLib::cMatrix4x4f::GetAxis4 ( int  nRow) const
inline

Get the axis + 1 extra as a cVector4f Only really useful for row-major matrices in a left-handed space. (Dx not OpenGL)

◆ GetDeterminant()

DVALUE_t GrayLib::cMatrix4x4f::GetDeterminant ( ) const
inline

D3DXMatrixDeterminant like D3DXMatrixfDeterminant

◆ GetInverse()

THIS_t GrayLib::cMatrix4x4f::GetInverse ( DVALUE_t pfDeterminant = nullptr) const
inline
Returns
Inverse of myself.

◆ GetMul()

THIS_t GrayLib::cMatrix4x4f::GetMul ( const THIS_t m2) const
inline
Returns
Matrix multiplication. result = *this * m2 like: D3DXMatrixMultiply

◆ GetTranspose()

THIS_t GrayLib::cMatrix4x4f::GetTranspose ( ) const
inline
Returns
Transpose of myself.

◆ InitIdentity()

void GrayLib::cMatrix4x4f::InitIdentity ( )
inline

Create an identity matrix All zero + scale of 1,1,1. no translation or rotation.

◆ InitInverse()

void GrayLib::cMatrix4x4f::InitInverse ( const THIS_t m1,
DVALUE_t pfDeterminant = nullptr 
)
inline

Create an inverted matrix. i.e. M1 * M1inverted = identity matrix

◆ InitLookAtLH()

void GrayLib::cMatrix4x4f::InitLookAtLH ( const cVector3f vEye,
const cVector3f vAt,
const cVector3f vUp 
)

Left Handed (DirectX) style

◆ InitMul()

void GrayLib::cMatrix4x4f::InitMul ( const THIS_t m1,
const THIS_t m2 
)
inline

Create a matrix with result of multiply of 2 matrices.

Note
Order is important when multiply of matrix! A*B != B*A like: D3DXMatrixMultiply
This can be simplified if we assume row 3 is [0 0 0 1] ??

◆ InitOrthoOffCenterLH()

void GrayLib::cMatrix4x4f::InitOrthoOffCenterLH ( DVALUE_t  l,
DVALUE_t  r,
DVALUE_t  b,
DVALUE_t  t,
DVALUE_t  zn,
DVALUE_t  zf 
)
inline

For left handed 3d space.

◆ InitPerspectiveFovLH()

void GrayLib::cMatrix4x4f::InitPerspectiveFovLH ( DVALUE_t  fovy,
DVALUE_t  aspect,
DVALUE_t  zn,
DVALUE_t  zf 
)
inline

Create a matrix For left handed 3d space.

Note
Left handed space represents texture coordinates more correctly. Used by DirectX Right handed space represents Cartesian plots more correctly. Used by OpenGL. thumb = z, index=x, middle = y

◆ InitReflect()

void GrayLib::cMatrix4x4f::InitReflect ( const cPlanef plane)

◆ InitRotationAxis()

void GrayLib::cMatrix4x4f::InitRotationAxis ( const cVector3f vAxis,
RADIANf_t  fAngle 
)
inline

Create a 3x3 rotation matrix around an arbitrary axis.

  • vAxis = [in] Pointer to the arbitrary axis. fAngle = [in] Euler Angle of rotation in radians. Angles are measured clockwise when looking along the rotation axis toward the origin.

◆ InitRotationQ()

void GrayLib::cMatrix4x4f::InitRotationQ ( const cQuaternionf q)
inline

Create a rotation matrix Set matrix rotation from quaternion.

◆ InitRotationX()

void GrayLib::cMatrix4x4f::InitRotationX ( RADIANf_t  fAngleX)
inline

Create a rotation matrix around x axis. x = Euler pitch.

◆ InitRotationY()

void GrayLib::cMatrix4x4f::InitRotationY ( RADIANf_t  fAngleY)
inline

Create a rotation matrix around y axis.

◆ InitRotationZ()

void GrayLib::cMatrix4x4f::InitRotationZ ( RADIANf_t  fAngleZ)
inline

Create a rotation matrix around z axis. z=roll=bank

◆ InitScaling() [1/3]

void GrayLib::cMatrix4x4f::InitScaling ( const cVector3f pt)
inline

◆ InitScaling() [2/3]

void GrayLib::cMatrix4x4f::InitScaling ( DVALUE_t  _x,
DVALUE_t  _y,
DVALUE_t  _z 
)
inline

Create a scaling matrix

Note
scale of 1,1,1 = identity matrix scale

◆ InitScaling() [3/3]

void GrayLib::cMatrix4x4f::InitScaling ( DVALUE_t  fScale)
inline

Create a scaling matrix fScale = 1 = identity.

◆ InitTransformation()

void GrayLib::cMatrix4x4f::InitTransformation ( const cVector3f pvScalingCenter = nullptr,
const cQuaternionf pqScalingRotation = nullptr,
const cVector3f pvScaling = nullptr,
const cVector3f pvRotationcenter = nullptr,
const cQuaternionf pqRotation = nullptr,
const cVector3f pvTranslation = nullptr 
)

◆ InitTransformation2D()

void GrayLib::cMatrix4x4f::InitTransformation2D ( const cVector2f pvScalingCenter = nullptr,
float  fScalingRotation = 0,
const cVector2f pvScaling = nullptr,
const cVector2f pvRotationCenter = nullptr,
RADIANf_t  fRotation = 0,
const cVector2f pvTranslation = nullptr 
)

◆ InitTranslation() [1/2]

void GrayLib::cMatrix4x4f::InitTranslation ( const cVector3f pt)
inline

Create a translation matrix

◆ InitTranslation() [2/2]

void GrayLib::cMatrix4x4f::InitTranslation ( DVALUE_t  x,
DVALUE_t  y,
DVALUE_t  z 
)
inline

Create a translation matrix

Note
Not a particularly efficient way to translate. usually used multiplied against other matrices.

◆ InitTranspose()

void GrayLib::cMatrix4x4f::InitTranspose ( const THIS_t m1)
inline
Note
OpenGL and DirectX are transposed by default ?

◆ InitYawPitchRoll()

void GrayLib::cMatrix4x4f::InitYawPitchRoll ( RADIANf_t  yaw,
RADIANf_t  pitch,
RADIANf_t  roll 
)

3x3 matrix for Euler angles. y=yaw=heading,x=pitch,z=roll=bank

Note
This is for DirectX LH style matrix/world not OpenGL RH style.

◆ isIdentity()

bool GrayLib::cMatrix4x4f::isIdentity ( ) const
inline

test for InitIdentity() D3DXMatrixIdentity test for near identity == IsNear( k_Identity );

◆ operator*()

THIS_t GrayLib::cMatrix4x4f::operator* ( const THIS_t m2) const
inline

◆ operator*=()

const THIS_t& GrayLib::cMatrix4x4f::operator*= ( const THIS_t m2)
inline

◆ operator-()

THIS_t GrayLib::cMatrix4x4f::operator- ( ) const
inline
Returns
inverted matrix.

◆ put_Scaling1()

void GrayLib::cMatrix4x4f::put_Scaling1 ( DVALUE_t  fScale = 0)
inline

Unify the scaling

◆ ref_Translation()

cVector3f& GrayLib::cMatrix4x4f::ref_Translation ( )
inline

< AXIS_Trans

◆ ref_XAxis()

cVector3f& GrayLib::cMatrix4x4f::ref_XAxis ( )
inline

< AXIS_X

◆ ref_YAxis()

cVector3f& GrayLib::cMatrix4x4f::ref_YAxis ( )
inline

< AXIS_Y

◆ ref_ZAxis()

cVector3f& GrayLib::cMatrix4x4f::ref_ZAxis ( )
inline

< AXIS_Z

◆ RefAxis3()

cVector3f& GrayLib::cMatrix4x4f::RefAxis3 ( AXIS_TYPE  eAxis)
inline

◆ RefAxis4()

cVector4f& GrayLib::cMatrix4x4f::RefAxis4 ( int  nRow)
inline

refer to axis as cVector4f

◆ SetInvert()

void GrayLib::cMatrix4x4f::SetInvert ( DVALUE_t pfDeterminant = nullptr)
inline

Invert myself.

◆ SetMul()

void GrayLib::cMatrix4x4f::SetMul ( const THIS_t m2)
inline

multiply against myself. this = this * m2

◆ SetNormalized()

void GrayLib::cMatrix4x4f::SetNormalized ( )
inline

Normalize the AXIS_TYPE vectors. WEIRD !? easier to just normalize the result of whatever the matrix is used for ?

◆ SetScaling()

void GrayLib::cMatrix4x4f::SetScaling ( DVALUE_t  _x,
DVALUE_t  _y,
DVALUE_t  _z 
)
inline

similar to InitScaling() D3DXMatrixScaling BUT NOT FULL INIT safely does not change the existing rotation.

Note
1,1,1 = identity matrix

◆ SetScalingT()

void GrayLib::cMatrix4x4f::SetScalingT ( DVALUE_t  _x,
DVALUE_t  _y,
DVALUE_t  _z 
)
inline

SetScaling Transposed. Was SetScale3

◆ SetTranslation()

void GrayLib::cMatrix4x4f::SetTranslation ( DVALUE_t  _x = 0,
DVALUE_t  _y = 0,
DVALUE_t  _z = 0 
)
inline

similar to D3DXMatrixTranslation and InitTranslation() BUT NOT FULL INIT Poke the translation into the matrix. This is safe.

◆ SetTranspose()

void GrayLib::cMatrix4x4f::SetTranspose ( )
inline

Transpose myself.

◆ UNITTEST_FRIEND()

GrayLib::cMatrix4x4f::UNITTEST_FRIEND ( cMatrix  )

Member Data Documentation

◆ k_Identity

const cMatrix4x4f GrayLib::cMatrix4x4f::k_Identity
static

◆ k_nDim

const int GrayLib::cMatrix4x4f::k_nDim = 4
static

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