Clutter Engine 0.0.1
Loading...
Searching...
No Matches
Matrix4 Struct Reference

A 4x4 matrix used for 3D transformations. More...

#include <Matrix4.h>

Public Member Functions

 Matrix4 ()
 Default constructor that initializes to identity matrix.
 
 Matrix4 (const array< float, 16 > &that)
 Constructs a matrix from an array of 16 floats.
 
const float * GetAsFloatPtr () const
 Gets a pointer to the raw matrix data.
 
float & operator() (const int i, const int j)
 Accesses matrix elements by row and column indices.
 
Matrix4operator= (const Matrix4 &that)
 Assignment operator.
 
Matrix4 operator+ (const Matrix4 &that) const
 Addition operator.
 
Matrix4operator+= (const Matrix4 &that)
 Compound addition operator.
 
Matrix4 operator- (const Matrix4 &that) const
 Subtraction operator.
 
Matrix4operator-= (const Matrix4 &that)
 Compound subtraction operator.
 
Matrix4operator*= (Matrix4 &right)
 Compound multiplication operator.
 
void Invert ()
 Inverts the matrix.
 
Vector3 GetTranslation () const
 Gets the translation component of the matrix.
 
Vector3 GetXAxis () const
 Gets the normalized X axis of the matrix.
 
Vector3 GetYAxis () const
 Gets the normalized Y axis of the matrix.
 
Vector3 GetZAxis () const
 Gets the normalized Z axis of the matrix.
 
Vector3 GetScale () const
 Gets the scale components of the matrix.
 

Static Public Member Functions

static Matrix4 CreateScale (float xScale, float yScale, float zScale)
 Creates a scaling matrix with separate scale factors for each axis.
 
static Matrix4 CreateScale (const Vector3 &scaleVector)
 Creates a scaling matrix from a Vector3.
 
static Matrix4 CreateScale (float scale)
 Creates a uniform scaling matrix.
 
static Matrix4 CreateRotationX (float theta)
 Creates a rotation matrix around the X axis.
 
static Matrix4 CreateRotationY (float theta)
 Creates a rotation matrix around the Y axis.
 
static Matrix4 CreateRotationZ (float theta)
 Creates a rotation matrix around the Z axis.
 
static Matrix4 CreateTranslation (const Vector3 &trans)
 Creates a translation matrix.
 
static Matrix4 CreateSimpleViewProj (float width, float height)
 Creates a simple 2D view-projection matrix.
 
static Matrix4 CreateFromQuaternion (const Quaternion &q)
 Creates a rotation matrix from a quaternion.
 
static Matrix4 CreateLookAt (const Vector3 &eye, const Vector3 &target, const Vector3 &up)
 Creates a view matrix for a camera.
 
static Matrix4 CreateOrtho (float width, float height, float pNear, float pFar)
 Creates an orthographic projection matrix.
 
static Matrix4 CreatePerspectiveFOV (float fovY, float width, float height, float pNear, float pFar)
 Creates a perspective projection matrix based on field of view.
 
static Matrix4 CreatePerspective (float left, float right, float bottom, float top, float pNear, float pFar)
 Creates a perspective projection matrix based on explicit frustum dimensions.
 

Public Attributes

array< float, 16 > mat
 The raw matrix data stored as a flat array of 16 floats in row-major order.
 

Static Public Attributes

static const Matrix4 Identity
 Identity matrix constant.
 

Friends

Matrix4 operator* (Matrix4 &a, Matrix4 &b)
 Matrix multiplication operator.
 

Detailed Description

A 4x4 matrix used for 3D transformations.

The Matrix4 struct represents a 4x4 matrix primarily used for 3D transformations such as translation, rotation, scaling, and projection. The matrix is stored in row-major order.

Constructor & Destructor Documentation

◆ Matrix4()

Matrix4::Matrix4 ( const array< float, 16 > & that)
inline

Constructs a matrix from an array of 16 floats.

Parameters
thatArray of 16 float values in row-major order.

Member Function Documentation

◆ CreateFromQuaternion()

static Matrix4 Matrix4::CreateFromQuaternion ( const Quaternion & q)
inlinestatic

Creates a rotation matrix from a quaternion.

Parameters
qThe quaternion representing the rotation.
Returns
A rotation matrix.

◆ CreateLookAt()

static Matrix4 Matrix4::CreateLookAt ( const Vector3 & eye,
const Vector3 & target,
const Vector3 & up )
inlinestatic

Creates a view matrix for a camera.

Parameters
eyePosition of the camera.
targetPoint the camera is looking at.
upUp vector for the camera.
Returns
A view matrix.

◆ CreateOrtho()

static Matrix4 Matrix4::CreateOrtho ( float width,
float height,
float pNear,
float pFar )
inlinestatic

Creates an orthographic projection matrix.

Parameters
widthWidth of the orthographic view volume.
heightHeight of the orthographic view volume.
pNearDistance to the near clipping plane.
pFarDistance to the far clipping plane.
Returns
An orthographic projection matrix.

◆ CreatePerspective()

static Matrix4 Matrix4::CreatePerspective ( float left,
float right,
float bottom,
float top,
float pNear,
float pFar )
inlinestatic

Creates a perspective projection matrix based on explicit frustum dimensions.

Parameters
leftLeft coordinate of the near clipping plane.
rightRight coordinate of the near clipping plane.
bottomBottom coordinate of the near clipping plane.
topTop coordinate of the near clipping plane.
pNearDistance to the near clipping plane.
pFarDistance to the far clipping plane.
Returns
A perspective projection matrix.

◆ CreatePerspectiveFOV()

static Matrix4 Matrix4::CreatePerspectiveFOV ( float fovY,
float width,
float height,
float pNear,
float pFar )
inlinestatic

Creates a perspective projection matrix based on field of view.

Parameters
fovYVertical field of view angle in radians.
widthWidth of the viewport.
heightHeight of the viewport.
pNearDistance to the near clipping plane.
pFarDistance to the far clipping plane.
Returns
A perspective projection matrix.

◆ CreateRotationX()

static Matrix4 Matrix4::CreateRotationX ( float theta)
inlinestatic

Creates a rotation matrix around the X axis.

Parameters
thetaRotation angle in radians.
Returns
A rotation matrix.

◆ CreateRotationY()

static Matrix4 Matrix4::CreateRotationY ( float theta)
inlinestatic

Creates a rotation matrix around the Y axis.

Parameters
thetaRotation angle in radians.
Returns
A rotation matrix.

◆ CreateRotationZ()

static Matrix4 Matrix4::CreateRotationZ ( float theta)
inlinestatic

Creates a rotation matrix around the Z axis.

Parameters
thetaRotation angle in radians.
Returns
A rotation matrix.

◆ CreateScale() [1/3]

static Matrix4 Matrix4::CreateScale ( const Vector3 & scaleVector)
inlinestatic

Creates a scaling matrix from a Vector3.

Parameters
scaleVectorVector containing scale factors for each axis.
Returns
A scaling matrix.

◆ CreateScale() [2/3]

static Matrix4 Matrix4::CreateScale ( float scale)
inlinestatic

Creates a uniform scaling matrix.

Parameters
scaleUniform scale factor for all axes.
Returns
A uniform scaling matrix.

◆ CreateScale() [3/3]

static Matrix4 Matrix4::CreateScale ( float xScale,
float yScale,
float zScale )
inlinestatic

Creates a scaling matrix with separate scale factors for each axis.

Parameters
xScaleScale factor for the X axis.
yScaleScale factor for the Y axis.
zScaleScale factor for the Z axis.
Returns
A scaling matrix.

◆ CreateSimpleViewProj()

static Matrix4 Matrix4::CreateSimpleViewProj ( float width,
float height )
inlinestatic

Creates a simple 2D view-projection matrix.

Parameters
widthWidth of the viewport.
heightHeight of the viewport.
Returns
A simple view-projection matrix for 2D rendering.

◆ CreateTranslation()

static Matrix4 Matrix4::CreateTranslation ( const Vector3 & trans)
inlinestatic

Creates a translation matrix.

Parameters
transVector containing the translation amounts along each axis.
Returns
A translation matrix.

◆ GetAsFloatPtr()

const float * Matrix4::GetAsFloatPtr ( ) const
inline

Gets a pointer to the raw matrix data.

Returns
A const float pointer to the beginning of the matrix data.

◆ GetScale()

Vector3 Matrix4::GetScale ( ) const
inline

Gets the scale components of the matrix.

Returns
A Vector3 containing the scale factors for each axis.

◆ GetTranslation()

Vector3 Matrix4::GetTranslation ( ) const
inline

Gets the translation component of the matrix.

Returns
A Vector3 containing the translation (elements [12], [13], [14]).

◆ GetXAxis()

Vector3 Matrix4::GetXAxis ( ) const
inline

Gets the normalized X axis of the matrix.

Returns
A normalized Vector3 representing the X axis.

◆ GetYAxis()

Vector3 Matrix4::GetYAxis ( ) const
inline

Gets the normalized Y axis of the matrix.

Returns
A normalized Vector3 representing the Y axis.

◆ GetZAxis()

Vector3 Matrix4::GetZAxis ( ) const
inline

Gets the normalized Z axis of the matrix.

Returns
A normalized Vector3 representing the Z axis.

◆ Invert()

void Matrix4::Invert ( )

Inverts the matrix.

Note
This is a computationally expensive operation.

◆ operator()()

float & Matrix4::operator() ( const int i,
const int j )
inline

Accesses matrix elements by row and column indices.

Parameters
iRow index (0-3).
jColumn index (0-3).
Returns
Reference to the specified matrix element.

◆ operator*=()

Matrix4 & Matrix4::operator*= ( Matrix4 & right)
inline

Compound multiplication operator.

Parameters
rightThe matrix to multiply this one by.
Returns
Reference to this matrix after multiplication.

◆ operator+()

Matrix4 Matrix4::operator+ ( const Matrix4 & that) const
inline

Addition operator.

Parameters
thatThe matrix to add to this one.
Returns
A new matrix containing the sum.

◆ operator+=()

Matrix4 & Matrix4::operator+= ( const Matrix4 & that)
inline

Compound addition operator.

Parameters
thatThe matrix to add to this one.
Returns
Reference to this matrix after addition.

◆ operator-()

Matrix4 Matrix4::operator- ( const Matrix4 & that) const
inline

Subtraction operator.

Parameters
thatThe matrix to subtract from this one.
Returns
A new matrix containing the difference.

◆ operator-=()

Matrix4 & Matrix4::operator-= ( const Matrix4 & that)
inline

Compound subtraction operator.

Parameters
thatThe matrix to subtract from this one.
Returns
Reference to this matrix after subtraction.

◆ operator=()

Matrix4 & Matrix4::operator= ( const Matrix4 & that)
inline

Assignment operator.

Parameters
thatThe matrix to copy from.
Returns
Reference to this matrix after assignment.

Friends And Related Symbol Documentation

◆ operator*

Matrix4 operator* ( Matrix4 & a,
Matrix4 & b )
friend

Matrix multiplication operator.

Parameters
aThe left-hand side matrix.
bThe right-hand side matrix.
Returns
The product matrix of a * b.

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