TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Math::Matrix3 Class Reference

#include <tb_matrix.h>

Public Member Functions

 Matrix3 (float f11=0.0f, float f21=0.0f, float f31=0.0f, float f12=0.0f, float f22=0.0f, float f32=0.0f, float f13=0.0f, float f23=0.0f, float f33=0.0f)
 
 Matrix3 (const float *const componentArray)
 
 Matrix3 (const SkipInitialization &fastAndStupid)
 
 Matrix3 (const Matrix3 &other)
 
Matrix3operator= (const Matrix3 &other)
 
bool operator== (const Matrix3 &other) const
 
bool operator!= (const Matrix3 &other) const
 
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)
 
Matrix3 operator* (float scalar) const
 

Static Public Member Functions

static Matrix3 Zero (void)
 
static Matrix3 Identity (void)
 

Public Attributes

union {
   float   mComponents [9]
 
   struct {
      float   m_f11
 
      float   m_f21
 
      float   m_f31
 
      float   m_f12
 
      float   m_f22
 
      float   m_f32
 
      float   m_f13
 
      float   m_f23
 
      float   m_f33
 
   } 
 
}; 
 

Detailed Description

The Matrix3 is a matrix of 9 float components that build a 3x3 matrix for transforms and other mathematical purposes.

Note
The 3x3 Matrix has not been tested as thoroughly as the 4x4 matrix which has been around since about 2005.

Constructor & Destructor Documentation

TurtleBrains::Math::Matrix3::Matrix3 ( float  f11 = 0.0f,
float  f21 = 0.0f,
float  f31 = 0.0f,
float  f12 = 0.0f,
float  f22 = 0.0f,
float  f32 = 0.0f,
float  f13 = 0.0f,
float  f23 = 0.0f,
float  f33 = 0.0f 
)
inlineexplicit

Constructs a Matrix3 object with the supplied components.

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

Constructs a Matrix3 object with the supplied float array.

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

Constructs a Matrix3 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::Matrix3::Matrix3 ( const Matrix3 other)
inline

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

Member Function Documentation

Vector3* TurtleBrains::Math::Matrix3::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 Matrix3. Do so at your own risk.

Note
This may actually become deprecated in the future, use at your own risk.
const Vector3* TurtleBrains::Math::Matrix3::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.

Note
This may actually become deprecated in the future, use at your own risk.
static Matrix3 TurtleBrains::Math::Matrix3::Identity ( void  )
inlinestatic

A constant Matrix3 value representing the identity matrix, with zeros for all components except for the diagonal.

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

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

TurtleBrains::Math::Matrix3::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.
bool TurtleBrains::Math::Matrix3::operator!= ( const Matrix3 other) const
inline

Inequality operator, compares each component of the Matrix3 object to the values of another Matrix4 returning true if the matrices are different using tbMath::IsEqual() to perform the floating equality check with tolerances allowed.

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

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

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

This operator returns a specific component of the Matrix3 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::Matrix3::operator() ( int  column,
int  row 
) const
inline

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

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

This operator returns a specific component of the Matrix3 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.

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

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

bool TurtleBrains::Math::Matrix3::operator== ( const Matrix3 other) const
inline

Equality operator, compares each component of the Matrix3 object to the values of another Matrix3 returning true if all components are equal, or false if any of the components are not equal using tbMath::IsEqual() to perform the floating equality check with tolerances allowed.

Parameters
otherThe Matrix3 object to compare against.
Note
Because the components are floating point values tbMath::IsEqual is used to compare the components for equality using the default tolerance: kTolerance.
const float& TurtleBrains::Math::Matrix3::operator[] ( const size_t &  index) const
inline

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

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

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

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

Sets the components of the Matrix3 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::Matrix3::SetBasis ( const size_t &  basisIndex,
float  basisX,
float  basisY,
float  basisZ 
)
inline

Sets the components of the Matrix3 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.
static Matrix3 TurtleBrains::Math::Matrix3::Zero ( void  )
inlinestatic

A constant Matrix3 value representing a zero'd matrix.