Isle
Loading...
Searching...
No Matches
Matrix4 Class Reference

4x4 Matrix class with virtual interface for manipulation and transformation. More...

#include <matrix.h>

Inheritance diagram for Matrix4:

Public Member Functions

 Matrix4 (float(*p_data)[4])
 Constructs a Matrix4 object referring to the given 4x4 float array. More...
 
virtual void Equals (float(*p_data)[4])
 Set the matrix elements from a 4x4 float array. More...
 
virtual void Equals (const Matrix4 &p_matrix)
 Copies the matrix from another Matrix4. More...
 
virtual void SetData (float(*p_data)[4])
 Set this matrix instance to use/point to a new 4x4 data block. More...
 
virtual void SetData (UnknownMatrixType &p_matrix)
 Copies the matrix data from a raw UnknownMatrixType instance. More...
 
virtual float(* GetData ())[4]
 Gets modifiable access to the 4x4 float matrix. More...
 
virtual float(* GetData () const)[4]
 Gets read-only access to the 4x4 float matrix data. More...
 
virtual float * Element (int p_row, int p_col)
 Accesses an individual element of the matrix in writable form. More...
 
virtual const float * Element (int p_row, int p_col) const
 Accesses an individual element in read-only form. More...
 
virtual void Clear ()
 Sets every element of the matrix to zero. More...
 
virtual void SetIdentity ()
 Sets this matrix to identity (diagonal 1, others 0). More...
 
virtual void operator= (const Matrix4 &p_matrix)
 Assign/copy another matrix's values into this one. More...
 
virtual Matrix4operator+= (float(*p_data)[4])
 In-place matrix addition with external float[4][4]. More...
 
virtual void TranslateBy (const float &p_x, const float &p_y, const float &p_z)
 Applies translation by amounts along X, Y, Z axes. More...
 
virtual void SetTranslation (const float &p_x, const float &p_y, const float &p_z)
 Overwrites the translation part of the matrix (last column). More...
 
virtual void Product (float(*p_a)[4], float(*p_b)[4])
 Multiplies two 4x4 float matrices, storing result in this. More...
 
virtual void Product (const Matrix4 &p_a, const Matrix4 &p_b)
 Multiplies two Matrix4s, storing result in this matrix. More...
 
virtual void ToQuaternion (Vector4 &p_resultQuat)
 Converts the 3x3 rotation part of this matrix to a quaternion (Vector4). More...
 
virtual int FromQuaternion (const Vector4 &p_vec)
 Initializes the matrix from a quaternion (Vector4). More...
 
void Scale (const float &p_x, const float &p_y, const float &p_z)
 Applies scaling factors along X, Y, and Z axes. More...
 
void RotateX (const float &p_angle)
 Applies a rotation (in radians or degrees, depending on implementation) about the X axis. More...
 
void RotateY (const float &p_angle)
 Applies a rotation (in radians or degrees, depending on implementation) about the Y axis. More...
 
void RotateZ (const float &p_angle)
 Applies a rotation (in radians or degrees) about the Z axis. More...
 
int BETA_1005a590 (Matrix4 &p_mat)
 [AI] Appears to perform some operation using another matrix, but function/purpose unknown. More...
 
void Swap (int p_d1, int p_d2)
 Swaps the data between two rows/columns (presumably). More...
 
float * operator[] (int idx)
 Array subscript operator for modifiable row access. More...
 
const float * operator[] (int idx) const
 Const array subscript operator for readonly row access. More...
 

Protected Attributes

float(* m_data )[4]
 Pointer to 4x4 float array, owns or refers to matrix data. More...
 

Detailed Description

4x4 Matrix class with virtual interface for manipulation and transformation.

[AI]

[AI] Abstracts a 4x4 matrix (typically for geometric use, such as transformations in 3D graphics). Provides various matrix operations, including assignment, translation, scaling, rotation, product (multiplication), identity creation, conversion to and from quaternion, and data access. Designed for polymorphic use with virtual methods, which is important for engine extensibility.

Definition at line 24 of file matrix.h.

Constructor & Destructor Documentation

◆ Matrix4()

Matrix4::Matrix4 ( float(*)  p_data[4])
inline

Constructs a Matrix4 object referring to the given 4x4 float array.

[AI]

Parameters
p_dataPointer to a 4x4 array of floats used as matrix data. [AI]

Definition at line 36 of file matrix.h.

Member Function Documentation

◆ BETA_1005a590()

int Matrix4::BETA_1005a590 ( Matrix4 p_mat)
inline

[AI] Appears to perform some operation using another matrix, but function/purpose unknown.

[AI] Calculates the inverse of this matrix and stores it in p_mat.

Parameters
p_matReference to another Matrix4. [AI]
Returns
Possibly an error code or count. [AI]

[AI]

Parameters
p_matReference to output matrix that receives the inverse. [AI]
Returns
0 for success, -1 if the matrix is singular (non-invertible). [AI]

[AI] Uses partial pivoting and Gaussian elimination for inversion.

◆ Clear()

void Matrix4::Clear ( )
inlinevirtual

Sets every element of the matrix to zero.

[AI] Sets all matrix elements to zero.

[AI]

[AI]

[AI] Effectively zeros out the entire matrix.

◆ Element() [1/2]

float * Matrix4::Element ( int  p_row,
int  p_col 
)
inlinevirtual

Accesses an individual element of the matrix in writable form.

[AI] Returns a pointer to the element at (row, col) in the matrix.

[AI]

Parameters
p_rowRow index (0-3). [AI]
p_colColumn index (0-3). [AI]
Returns
Pointer to the float element at the specified row and column. [AI]

[AI]

Parameters
p_rowRow index (0-3). [AI]
p_colColumn index (0-3). [AI]
Returns
Pointer to the specific float element within the matrix. [AI]

◆ Element() [2/2]

const float * Matrix4::Element ( int  p_row,
int  p_col 
) const
inlinevirtual

Accesses an individual element in read-only form.

[AI] Const overload.

[AI]

Parameters
p_rowRow index. [AI]
p_colColumn index. [AI]
Returns
Const pointer to the float element at the specified row/col. [AI]

Returns a pointer to the (row, col) element in the matrix. [AI]

Parameters
p_rowRow index (0-3). [AI]
p_colColumn index (0-3). [AI]
Returns
Const pointer to the matrix element at specified row/column. [AI]

◆ Equals() [1/2]

void Matrix4::Equals ( const Matrix4 p_matrix)
inlinevirtual

Copies the matrix from another Matrix4.

[AI] Copies the values from another Matrix4 into this matrix.

[AI]

Parameters
p_matrixReference to another matrix to copy from. [AI]
p_matrixSource matrix to copy from. [AI]

[AI] Uses memcpy for efficient copying of the matrix data.

◆ Equals() [2/2]

void Matrix4::Equals ( float(*)  p_data[4])
inlinevirtual

Set the matrix elements from a 4x4 float array.

[AI] Copies a 4x4 matrix from an external float array to the internal matrix data.

[AI]

Parameters
p_dataPointer to an external 4x4 float data array. [AI]
p_data4x4 float array (column-major order) to copy into this matrix. [AI]

[AI] Performs a memory copy of the input data to the matrix's internal storage.

◆ FromQuaternion()

int Matrix4::FromQuaternion ( const Vector4 p_vec)
inlinevirtual

Initializes the matrix from a quaternion (Vector4).

[AI] Sets this matrix from a quaternion representing rotation.

[AI]

Parameters
p_vecQuaternion as Vector4. [AI]
Returns
0 on failure, nonzero on success. [AI]

[AI]

Parameters
p_vecQuaternion (Vector4, x,y,z,w) to construct a rotation matrix. [AI]
Returns
0 on success, -1 on failure (e.g., input is not a unit quaternion). [AI]

◆ GetData() [1/2]

virtual float(* Matrix4::GetData ( ) )[4] const
inlinevirtual

Gets read-only access to the 4x4 float matrix data.

[AI]

Returns
Const pointer to the 4x4 float array used by the Matrix4. [AI]

◆ GetData() [2/2]

float(* Matrix4::GetData ( ) )[4]
inlinevirtual

Gets modifiable access to the 4x4 float matrix.

[AI] Const overload for retrieving matrix data pointer.

[AI] Returns a pointer to the raw 4x4 float matrix data.

[AI]

Returns
Pointer to the 4x4 float array used by the Matrix4. [AI]

[AI]

Returns
Pointer to the 4x4 array of floats representing the matrix data. [AI]
Const pointer to the 4x4 float matrix data. [AI]

◆ operator+=()

Matrix4 & Matrix4::operator+= ( float(*)  p_data[4])
inlinevirtual

In-place matrix addition with external float[4][4].

[AI] Adds all corresponding elements of a float[4][4] to this matrix.

[AI]

Parameters
p_dataFlat pointer to matrix to sum. [AI]
Returns
Reference to the modified matrix. [AI]
Parameters
p_dataSource float[4][4] whose elements are added to the matrix. [AI]
Returns
Reference to this matrix, after addition. [AI]

[AI] Adds raw values in-place compared to array-style addition.

◆ operator=()

void Matrix4::operator= ( const Matrix4 p_matrix)
inlinevirtual

Assign/copy another matrix's values into this one.

[AI] Assigns all values from another matrix to this one.

[AI]

Parameters
p_matrixSource matrix to assign from. [AI]
p_matrixSource matrix whose values will be copied. [AI]

[AI] Equivalent to Equals(const Matrix4&).

Reimplemented in MxMatrix.

◆ operator[]() [1/2]

float * Matrix4::operator[] ( int  idx)
inline

Array subscript operator for modifiable row access.

[AI]

Parameters
idxRow index (0-3). [AI]
Returns
Pointer to the row's float array. [AI]

Definition at line 201 of file matrix.h.

◆ operator[]() [2/2]

const float * Matrix4::operator[] ( int  idx) const
inline

Const array subscript operator for readonly row access.

[AI]

Parameters
idxRow index (0-3). [AI]
Returns
Const pointer to the row's float data. [AI]

Definition at line 208 of file matrix.h.

◆ Product() [1/2]

void Matrix4::Product ( const Matrix4 p_a,
const Matrix4 p_b 
)
inlinevirtual

Multiplies two Matrix4s, storing result in this matrix.

[AI] Multiplies two Matrix4 objects and stores result in this matrix.

[AI]

Parameters
p_aFirst operand Matrix4. [AI]
p_bSecond operand Matrix4. [AI]
p_aFirst operand matrix. [AI]
p_bSecond operand matrix. [AI]

[AI] Internally calls Product() with their data pointers.

◆ Product() [2/2]

void Matrix4::Product ( float(*)  p_a[4],
float(*)  p_b[4] 
)
inlinevirtual

Multiplies two 4x4 float matrices, storing result in this.

[AI] Multiplies two 4x4 float matrices, storing result in this matrix.

[AI]

Parameters
p_aFirst matrix operand (left-hand side). [AI]
p_bSecond matrix operand (right-hand side). [AI]

[AI]

Parameters
p_aPointer to first operand 4x4 matrix. [AI]
p_bPointer to second operand 4x4 matrix. [AI]

[AI] Standard matrix multiplication: this = p_a * p_b.

◆ RotateX()

void Matrix4::RotateX ( const float &  p_angle)
inline

Applies a rotation (in radians or degrees, depending on implementation) about the X axis.

[AI] Rotates the matrix around the X axis by the specified angle (in radians).

[AI]

Parameters
p_angleAngle of rotation (in radians/degrees as used in implementation). [AI]

[AI]

Parameters
p_angleAngle in radians to rotate. [AI]

[AI] Modifies relevant elements in place using the rotation formula.

◆ RotateY()

void Matrix4::RotateY ( const float &  p_angle)
inline

Applies a rotation (in radians or degrees, depending on implementation) about the Y axis.

[AI] Rotates the matrix around the Y axis by the specified angle (in radians).

[AI]

Parameters
p_angleAngle of rotation. [AI]

[AI]

Parameters
p_angleAngle in radians. [AI]

◆ RotateZ()

void Matrix4::RotateZ ( const float &  p_angle)
inline

Applies a rotation (in radians or degrees) about the Z axis.

[AI] Rotates the matrix around the Z axis by the specified angle (in radians).

[AI]

Parameters
p_angleAngle of rotation. [AI]

[AI]

Parameters
p_angleAngle in radians. [AI]

◆ Scale()

void Matrix4::Scale ( const float &  p_x,
const float &  p_y,
const float &  p_z 
)
inline

Applies scaling factors along X, Y, and Z axes.

[AI] Scales the matrix by the given x, y, z factors along each respective axis.

[AI]

Parameters
p_xScale factor for X axis. [AI]
p_yScale factor for Y axis. [AI]
p_zScale factor for Z axis. [AI]

[AI]

Parameters
p_xScaling factor for X dimension. [AI]
p_yScaling factor for Y dimension. [AI]
p_zScaling factor for Z dimension. [AI]

[AI] Multiplies the respective matrix columns by the factors.

◆ SetData() [1/2]

void Matrix4::SetData ( float(*)  p_data[4])
inlinevirtual

Set this matrix instance to use/point to a new 4x4 data block.

[AI] Sets the internal matrix storage pointer to the given array.

[AI]

Parameters
p_dataPointer to a new 4x4 float array. [AI]

(No copy: shallow set) [AI]

Parameters
p_dataPointer to the new 4x4 float array to use as matrix data. [AI]

[AI] This does not copy the values. Use with care regarding data ownership.

◆ SetData() [2/2]

void Matrix4::SetData ( UnknownMatrixType p_matrix)
inlinevirtual

Copies the matrix data from a raw UnknownMatrixType instance.

[AI] Sets the internal matrix storage pointer from an UnknownMatrixType.

[AI]

Parameters
p_matrixSource UnknownMatrixType containing a 4x4 float array. [AI]

(No copy: shallow set) [AI]

Parameters
p_matrixSource unknown matrix type whose internal data will be used for this matrix. [AI]

[AI] This operation sets the internal data pointer directly.

◆ SetIdentity()

void Matrix4::SetIdentity ( )
inlinevirtual

Sets this matrix to identity (diagonal 1, others 0).

[AI] Sets this matrix to the identity matrix.

[AI]

[AI]

[AI] Clears the matrix and sets the main diagonal to 1.

◆ SetTranslation()

void Matrix4::SetTranslation ( const float &  p_x,
const float &  p_y,
const float &  p_z 
)
inlinevirtual

Overwrites the translation part of the matrix (last column).

[AI] Sets the translation portion of the matrix to specified values.

[AI]

Parameters
p_xNew translation X. [AI]
p_yNew translation Y. [AI]
p_zNew translation Z. [AI]

[AI]

Parameters
p_xX translation value. [AI]
p_yY translation value. [AI]
p_zZ translation value. [AI]

[AI] Directly writes the values rather than incrementing (see TranslateBy).

◆ Swap()

void Matrix4::Swap ( int  p_d1,
int  p_d2 
)
inline

Swaps the data between two rows/columns (presumably).

[AI] Swaps two matrix rows.

[AI]

Parameters
p_d1First index (row/column). [AI]
p_d2Second index (row/column). [AI]

[AI]

Parameters
p_d1First row to swap. [AI]
p_d2Second row to swap. [AI]

[AI] Used primarily by matrix inversion algorithms for row operations.

◆ ToQuaternion()

void Matrix4::ToQuaternion ( Vector4 p_resultQuat)
inlinevirtual

Converts the 3x3 rotation part of this matrix to a quaternion (Vector4).

[AI] Converts this rotation/transform matrix to a quaternion.

[AI]

Parameters
p_resultQuatReference to destination quaternion (Vector4). [AI]
p_outQuatOutput quaternion (Vector4 format: x,y,z,w), filled by the function. [AI]

[AI] Handles both general and edge cases for numerical consistency. Assumes the matrix represents a rotation. [AI]

◆ TranslateBy()

void Matrix4::TranslateBy ( const float &  p_x,
const float &  p_y,
const float &  p_z 
)
inlinevirtual

Applies translation by amounts along X, Y, Z axes.

[AI] Adds a translation vector to the translation row of the matrix (usually row 3).

[AI]

Parameters
p_xAmount to translate along X. [AI]
p_yAmount to translate along Y. [AI]
p_zAmount to translate along Z. [AI]

[AI]

Parameters
p_xX component of translation. [AI]
p_yY component of translation. [AI]
p_zZ component of translation. [AI]

[AI] Adjusts only the translation part of the matrix.

Member Data Documentation

◆ m_data

float(* Matrix4::m_data)[4]
protected

Pointer to 4x4 float array, owns or refers to matrix data.

[AI]

Definition at line 29 of file matrix.h.


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