Ocular Engine
Ocular::Math::Matrix4x4 Class Reference

A 4x4 column-major float matrix. More...

#include <Matrix4x4.hpp>

Public Member Functions

 Matrix4x4 (float x0, float y0, float z0, float w0, float x1, float y1, float z1, float w1, float x2, float y2, float z2, float w2, float x3, float y3, float z3, float w3)
 
 Matrix4x4 (Matrix3x3 const &matrix)
 
 Matrix4x4 (float const *values)
 
 Matrix4x4 (Vector4< float > const &col0, Vector4< float > const &col1, Vector4< float > const &col2, Vector4< float > const &col3)
 
 Matrix4x4 (Vector3< float > const &position, Quaternion const &rotation)
 
 Matrix4x4 (Vector3< float > const &position, Vector3< float > const &eulerRotation)
 
 Matrix4x4 (Vector3< float > const &position, Quaternion const &rotation, Vector3< float > const &scale)
 
 Matrix4x4 (Matrix4x4_Internal const &data)
 
 Matrix4x4 (Matrix4x4 const &other)
 
 Matrix4x4 ()
 
float operator[] (uint32_t index)
 
Matrix4x4operator= (Matrix4x4 const &rhs)
 
Matrix4x4operator+= (Matrix4x4 const &rhs)
 
Matrix4x4operator-= (Matrix4x4 const &rhs)
 
Matrix4x4operator*= (Matrix4x4 const &rhs)
 
Matrix4x4operator*= (Vector4< float > const &rhs)
 
Matrix4x4operator*= (float rhs)
 
void setElement (uint32_t index, float value)
 
float getElement (uint32_t index) const
 
void setRow (uint32_t index, Vector4< float > const &row)
 
void setRow (uint32_t index, Vector3< float > const &row)
 
void getRow (uint32_t index, Vector4< float > &row) const
 
Vector4< float > getRow (uint32_t index) const
 
void setCol (uint32_t index, Vector4< float > const &col)
 
void setCol (uint32_t index, Vector3< float > const &col)
 
void getCol (uint32_t index, Vector4< float > &col) const
 
Vector4< float > getCol (uint32_t index) const
 
void setData (float const *data)
 
void getData (float *data) const
 
void invert ()
 
Matrix4x4 getInverse () const
 
float getDeterminant () const
 
Matrix4x4 getTranspose () const
 
bool isIdentity () const
 
Matrix4x4_InternalgetInternal () const
 

Static Public Member Functions

static Matrix4x4 CreateTranslationMatrix (Vector3< float > const &translate, Matrix4x4 const &matrix=Matrix4x4())
 
static Matrix4x4 CreateScaleMatrix (Vector3< float > const &scale, Matrix4x4 const &matrix=Matrix4x4())
 
static Matrix4x4 CreateLookAtMatrix (Vector3< float > const &from, Vector3< float > const &to, Vector3< float > const &up)
 
static Matrix4x4 CreateOrthographicMatrix (float xMin, float xMax, float yMin, float yMax, float nearClip, float farClip)
 
static Matrix4x4 CreatePerspectiveMatrix (float fov, float aspectRatio, float nearClip, float farClip)
 

Detailed Description

A 4x4 column-major float matrix.

x.x y.x z.x t.x x.y y.y z.y t.y x.z y.z z.z t.z 0.0 0.0 0.0 1.0

00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33

00 04 08 12 01 05 09 13 02 06 10 14 03 07 11 15

Constructor & Destructor Documentation

Ocular::Math::Matrix4x4::Matrix4x4 ( float  x0,
float  y0,
float  z0,
float  w0,
float  x1,
float  y1,
float  z1,
float  w1,
float  x2,
float  y2,
float  z2,
float  w2,
float  x3,
float  y3,
float  z3,
float  w3 
)

Creates a new 4x4 column-major matrix.

Parameters
[in]x0First element of the x-rotation column
[in]y0First element of the y-rotation column
[in]z0First element of the z-rotation column
[in]w0First element of the position column
[in]x1Second element of the x-rotation column
[in]y1Second element of the y-rotation column
[in]z1Second element of the z-rotation column
[in]w1Second element of the position column
[in]x2Third element of the x-rotation column
[in]y2Third element of the y-rotation column
[in]z2Third element of the z-rotation column
[in]w2Third element of the position column
[in]x3Fourth element of the x-rotation column
[in]y3Fourth element of the y-rotation column
[in]z3Fourth element of the z-rotation column
[in]w3Fourth element of the position column
Ocular::Math::Matrix4x4::Matrix4x4 ( Matrix3x3 const &  matrix)

Creates a new 4x4 column-major matrix from an existing 3x3 column-major matrix.

Parameters
[in]matrix
Ocular::Math::Matrix4x4::Matrix4x4 ( float const *  values)

Creates a new 4x4 column-major matrix.

Parameters
[in]values16-element float array of values in column-major order ({x0, x1, x2, x3, ..., w0, w1, w2, w3})
Ocular::Math::Matrix4x4::Matrix4x4 ( Vector3< float > const &  position,
Quaternion const &  rotation 
)

Constructs a 4x4 matrix using a position and rotation.

Parameters
[in]position
[in]rotation
Ocular::Math::Matrix4x4::Matrix4x4 ( Vector3< float > const &  position,
Vector3< float > const &  eulerRotation 
)

Constructs a 4x4 matrix using a set of euler angles and position.

Parameters
[in]position
[in]eulerRotation(pitch, yaw, roll)
Ocular::Math::Matrix4x4::Matrix4x4 ( )

Creates a new identity Matrix

Member Function Documentation

Matrix4x4 Ocular::Math::Matrix4x4::CreateLookAtMatrix ( Vector3< float > const &  from,
Vector3< float > const &  to,
Vector3< float > const &  up 
)
static
Parameters
[in]fromOrigin (eye) point
[in]toPoint in space to look at
[in]upThe up vector
Matrix4x4 Ocular::Math::Matrix4x4::CreateOrthographicMatrix ( float  xMin,
float  xMax,
float  yMin,
float  yMax,
float  nearClip,
float  farClip 
)
static
Parameters
[in]xMin
[in]xMax
[in]yMin
[in]yMax
[in]nearClipDistance to the near clipping plane
[in]farClipDistance to the far clipping plane
Matrix4x4 Ocular::Math::Matrix4x4::CreatePerspectiveMatrix ( float  fov,
float  aspectRatio,
float  nearClip,
float  farClip 
)
static
Parameters
[in]fovField-of-view in degrees
[in]aspectRatioRelation between the view width and height (width / height)
[in]nearClipDistance to the near clipping plane
[in]farClipDistance to the far clipping plane
Matrix4x4 Ocular::Math::Matrix4x4::CreateScaleMatrix ( Vector3< float > const &  scale,
Matrix4x4 const &  matrix = Matrix4x4() 
)
static
Parameters
[in]scaleThe scaling to apply
[in]matrixOptional matrix to apply the scaling to
Returns
A matrix that performs the specified scaling (if non-identity matrix is supplied, then that matrix after the scaling)
Matrix4x4 Ocular::Math::Matrix4x4::CreateTranslationMatrix ( Vector3< float > const &  translate,
Matrix4x4 const &  matrix = Matrix4x4() 
)
static
Parameters
[in]translateThe translate vector to apply
[in]matrixOptional matrix to apply the translation to
Returns
A matrix that performs the specified translation (if non-identity matrix is supplied, then that matrix after the translation)
void Ocular::Math::Matrix4x4::getCol ( uint32_t  index,
Vector4< float > &  col 
) const

Retrieves the value of a single column of the matrix.

Parameters
[in]indexColumn index [0, 4)
[out]colVector to store the column values
void Ocular::Math::Matrix4x4::getData ( float *  data) const

Retrieves the matrix data values as an array of floats.

Parameters
[out]dataAn array of at least 16 floating point values (if more, only the first 16 are filled).
float Ocular::Math::Matrix4x4::getElement ( uint32_t  index) const

Returns an individual element of the matrix. Matrix elements are ordered as follows:

{rotX.x, rotX.y, rotX.z, rotX.w, rotY.x, rotY.y, rotY.z, rotY.w, rotZ.x, rotZ.y, rotZ.z, rotZ.w, pos.x, pos.y, pos.z, pos.w}

or

00 04 08 12
01 05 09 13
02 06 10 14
03 07 11 15
Parameters
[in]indexElement index to retrieve [0, 16)
Returns
Element value at the specified index.
Matrix4x4_Internal * Ocular::Math::Matrix4x4::getInternal ( ) const

For internal use only. Only modify this pointer if you want your application to crash.

void Ocular::Math::Matrix4x4::getRow ( uint32_t  index,
Vector4< float > &  row 
) const

Retrieves the value of a single row of the matrix.

Parameters
[in]indexRow index [0, 4)
[out]rowVector to store the row values
bool Ocular::Math::Matrix4x4::isIdentity ( ) const
Returns
TRUE if the matrix is an identity matrix.
void Ocular::Math::Matrix4x4::setCol ( uint32_t  index,
Vector4< float > const &  col 
)

Sets the value of a single column of the matrix.

Parameters
[in]indexColumn index [0,4)
[in]colVector of column values
void Ocular::Math::Matrix4x4::setData ( float const *  data)

Sets the matrix data values from an array of floats.

Parameters
[in]dataAn array of at least 16 floating point values (if more, only the first 16 are used).
void Ocular::Math::Matrix4x4::setElement ( uint32_t  index,
float  value 
)

Sets an individual element of the matrix. Matrix elements are ordered as follows:

{rotX.x, rotX.y, rotX.z, rotX.w, rotY.x, rotY.y, rotY.z, rotY.w, rotZ.x, rotZ.y, rotZ.z, rotZ.w, pos.x, pos.y, pos.z, pos.w}

or

00 04 08 12
01 05 09 13
02 06 10 14
03 07 11 15
Parameters
[in]indexElement index to set [0, 16)
[in]valueValue to set the element to
void Ocular::Math::Matrix4x4::setRow ( uint32_t  index,
Vector4< float > const &  row 
)

Sets the value of a single row of the matrix.

Parameters
[in]indexRow index [0,4)
[in]rowVector of row values

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