TurtleBrains  0.2.1
High quality, portable, C++ API for native application and game development.
TurtleBrains::Math::Matrix4 Class Reference

#include <tb_matrix.h>

Public Member Functions

 Matrix4 (float f11=0.0f, float f21=0.0f, float f31=0.0f, float f41=0.0f, float f12=0.0f, float f22=0.0f, float f32=0.0f, float f42=0.0f, float f13=0.0f, float f23=0.0f, float f33=0.0f, float f43=0.0f, float f14=0.0f, float f24=0.0f, float f34=0.0f, float f44=0.0f)
 
 Matrix4 (const float *const componentArray)
 
 Matrix4 (const SkipInitialization &fastAndStupid)
 
 Matrix4 (const Matrix4 &other)
 
Matrix4operator= (const Matrix4 &other)
 
const float & operator[] (const size_t &index) const
 
float & operator[] (const size_t &index)
 
const float & operator() (const size_t &column, const size_t &row) const
 
float & operator() (const size_t &column, const size_t &row)
 
const float & operator() (int column, int row) const
 
float & operator() (int column, int row)
 
 operator float * (void)
 
 operator const float * (void) const
 
Vector3GetBasis (const size_t &basisIndex)
 
const Vector3GetBasis (const size_t &basisIndex) const
 
void SetBasis (const size_t &basisIndex, const Vector3 &basis)
 
void SetBasis (const size_t &basisIndex, float basisX, float basisY, float basisZ)
 
Vector3 GetPosition (void) const
 
void SetPosition (const Vector3 &position)
 
void SetPosition (float x, float y, float z)
 
Matrix4 GetTransposed (void) const
 

Public Attributes

union {
   float   mComponents [16]
 
   struct {
      float   m_f11
 
      float   m_f21
 
      float   m_f31
 
      float   m_f41
 
      float   m_f12
 
      float   m_f22
 
      float   m_f32
 
      float   m_f42
 
      float   m_f13
 
      float   m_f23
 
      float   m_f33
 
      float   m_f43
 
      float   m_f14
 
      float   m_f24
 
      float   m_f34
 
      float   m_f44
 
   } 
 
}; 
 

Static Public Attributes

static const Matrix4 kZero
 
static const Matrix4 kIdentity
 

Detailed Description

------------------------------------------------------------------------------------------------------------——/// ------------------------------------------------------------------------------------------------------------——/// ------------------------------------------------------------------------------------------------------------——///

The Matrix4 is a matrix of 16 float components that build a 4x4 matrix for transforms and other mathematical purposes.

Constructor & Destructor Documentation

TurtleBrains::Math::Matrix4::Matrix4 ( float  f11 = 0.0f,
float  f21 = 0.0f,
float  f31 = 0.0f,
float  f41 = 0.0f,
float  f12 = 0.0f,
float  f22 = 0.0f,
float  f32 = 0.0f,
float  f42 = 0.0f,
float  f13 = 0.0f,
float  f23 = 0.0f,
float  f33 = 0.0f,
float  f43 = 0.0f,
float  f14 = 0.0f,
float  f24 = 0.0f,
float  f34 = 0.0f,
float  f44 = 0.0f 
)
inlineexplicit

Constructs a Matrix4 object with the supplied components.

TurtleBrains::Math::Matrix4::Matrix4 ( const float *const  componentArray)
inlineexplicit

Constructs a Matrix4 object with the supplied float array.

Parameters
componentArrayMust have at least 16 floats, one for each component in the Matrix4.
TurtleBrains::Math::Matrix4::Matrix4 ( const SkipInitialization fastAndStupid)
inlineexplicit

Constructs a Matrix4 object leaving the members uninitialized and must be initialized manually before the object is used.

Note
Should be used only if the consequences are understood, and even then only sparingly.
TurtleBrains::Math::Matrix4::Matrix4 ( const Matrix4 other)
inline

Constructs a Matrix4 object by copying the component values from an existing Matrix4 object.

Member Function Documentation

Vector3* TurtleBrains::Math::Matrix4::GetBasis ( const size_t &  basisIndex)
inline

Returns a pointer to a Vector3 object whos components are the same components as the basis it represents. This is making assumptions that the Vector3 internally operates on an array of three floats. Modifying the returned Vector3 will modify the Matrix4. Do so at your own risk.

Note
This may actually become deprecated in the future, use at your own risk.
const Vector3* TurtleBrains::Math::Matrix4::GetBasis ( const size_t &  basisIndex) const
inline

Returns a pointer to a Vector3 object whos components are the same components as the basis it represents. This is making assumptions that the Vector3 internally operates on an array of three floats. Modifying the returned Vector3 will modify the Matrix4. Do so at your own risk.

Note
This may actually become deprecated in the future, use at your own risk.
Vector3 TurtleBrains::Math::Matrix4::GetPosition ( void  ) const
inline

Much like the GetBasis accesses a specific axis of the Matrix4 object, this will return the amount of translation the transform Matrix4 has. However it can not be modified and due to the location of the position components, a temporary Vector3 must be created.

Matrix4 TurtleBrains::Math::Matrix4::GetTransposed ( void  ) const
inline

Creates a matrix object with the components transposed and returns the results.

TurtleBrains::Math::Matrix4::operator const float * ( void  ) const
inline

This operator returns the array of components used by the Matrix4 object.

TurtleBrains::Math::Matrix4::operator float * ( void  )
inline

This operator returns the array of components used by the Matrix4 object. If the returned array is modified, the internal array will also be modified. Only use this if you understand the meaning.

Note
This may actually become deprecated in the future, use at your own risk.
const float& TurtleBrains::Math::Matrix4::operator() ( const size_t &  column,
const size_t &  row 
) const
inline

This operator returns a specific component of the Matrix4 object picked by the column and row parameters.

float& TurtleBrains::Math::Matrix4::operator() ( const size_t &  column,
const size_t &  row 
)
inline

This operator returns a specific component of the Matrix4 object picked by the column and row parameters. The component is returned by reference and can then be modified externally. Do so at your own risk.

const float& TurtleBrains::Math::Matrix4::operator() ( int  column,
int  row 
) const
inline

This operator returns a specific component of the Matrix4 object picked by the column and row parameters.

float& TurtleBrains::Math::Matrix4::operator() ( int  column,
int  row 
)
inline

This operator returns a specific component of the Matrix4 object picked by the column and row parameters. The component is returned by reference and can then be modified externally. Do so at your own risk.

Matrix4& TurtleBrains::Math::Matrix4::operator= ( const Matrix4 other)
inline

Assigns each component in the Matrix object to match an existing Matrix4 object.

const float& TurtleBrains::Math::Matrix4::operator[] ( const size_t &  index) const
inline

This operator returns a specific component of the Matrix4 object picked by the index which can be from 0 to 15 for a Matrix4 object.

float& TurtleBrains::Math::Matrix4::operator[] ( const size_t &  index)
inline

This operator returns a specific component of the Matrix4 object picked by the index which can be from 0 to 15 for a Matrix4 object. The component is returned by reference and can then be modified externally. Do so at your own risk.

void TurtleBrains::Math::Matrix4::SetBasis ( const size_t &  basisIndex,
const Vector3 basis 
)
inline

Sets the components of the Matrix4 basis to the values set in the supplied Vector object.

Parameters
basisIndexThe basis to set, 0 is the X basis, 1 is the Y basis and 2 is the Z basis.
basisThe value of each component of the basis vector to be set in the Matrix object.
void TurtleBrains::Math::Matrix4::SetBasis ( const size_t &  basisIndex,
float  basisX,
float  basisY,
float  basisZ 
)
inline

Sets the components of the Matrix4 basis to the values supplied by the basisX, Y, Z parameters.

Parameters
basisIndexThe basis to set, 0 is the X basis, 1 is the Y basis and 2 is the Z basis.
basisXThe Value to set the basis X component to.
basisYThe Value to set the basis Y component to.
basisZThe Value to set the basis X component to.
void TurtleBrains::Math::Matrix4::SetPosition ( const Vector3 position)
inline

Much like the SetBasis modified a specific axis of the Matrix4 object, this will modify the translation/position of the transform Matrix4 to be the values of the Vector3 object supplied.

void TurtleBrains::Math::Matrix4::SetPosition ( float  x,
float  y,
float  z 
)
inline

Much like the SetBasis modified a specific axis of the Matrix4 object, this will modify the translation/position of the transform Matrix4 to be the values supplied.

Member Data Documentation

const Matrix4 TurtleBrains::Math::Matrix4::kIdentity
static

A constant Matrix4 value representing the identity matrix, with zeros for all components except for the diagonal: { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f }

const Matrix4 TurtleBrains::Math::Matrix4::kZero
static

A constant Matrix4 value representing a zero'd matrix.