Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
Ult::Matrix4x4 Class Reference

#include <Matrix4x4.h>

Public Member Functions

 Matrix4x4 ()
 
 Matrix4x4 (const float r11, const float r12, const float r13, const float r14, const float r21, const float r22, const float r23, const float r24, const float r31, const float r32, const float r33, const float r34, const float r41, const float r42, const float r43, const float r44)
 
void Add (const Matrix4x4 &m1, const Matrix4x4 &m2)
 
void Subtract (const Matrix4x4 &m1, const Matrix4x4 &m2)
 
void Multiple (const Matrix4x4 &m1, const Matrix4x4 &m2)
 
void operator= (const Matrix4x4 &m)
 
Matrix4x4 operator- (const Matrix4x4 &m) const
 
Matrix4x4 operator+ (const Matrix4x4 &m) const
 
Matrix4x4 operator* (const Matrix4x4 &m) const
 
void Identity ()
 
void Zero ()
 
void Translate (const Vector3D &v)
 
void Translate (const float x, const float y, const float z)
 
Vector3D InverseTranslateVector (const Vector3D &v) const
 
bool InverseMatrix (const Matrix4x4 &m)
 
void InvertMatrix (const Matrix4x4 &m)
 
Vector3D VectorMatrixMultiply (const Vector3D &v) const
 
Vector3D VectorMatrixMultiply3x3 (const Vector3D &v) const
 
Vector3D VectorMatrixMultiply3x3Inv (const Vector3D &v) const
 
void Transpose (const Matrix4x4 &m)
 
void Scale (const Vector3D &scale)
 
void SetRotationRadians (const float x, const float y, const float z)
 
void Rotate (const float angleDegrees, const int x, const int y, const int z)
 
void RotateAxis (const float angleDegrees, const Vector3D &axis)
 
void RotateX (const float angleDegrees)
 
void RotateY (const float angleDegrees)
 
void RotateZ (const float angleDegrees)
 
void CreateViewMatrix (const Vector3D &pos, const Vector3D &dir, const Vector3D &up, const Vector3D &right)
 

Public Attributes

float matrix [16]
 

Detailed Description

Matrix with 4 rows and 4 columns.

Constructor & Destructor Documentation

◆ Matrix4x4() [1/2]

Ult::Matrix4x4::Matrix4x4 ( )

Matrix4x4 constructor. Defaults values to an identity matrix.

◆ Matrix4x4() [2/2]

Ult::Matrix4x4::Matrix4x4 ( const float r11,
const float r12,
const float r13,
const float r14,
const float r21,
const float r22,
const float r23,
const float r24,
const float r31,
const float r32,
const float r33,
const float r34,
const float r41,
const float r42,
const float r43,
const float r44 )

Matrix4x4 constructor from 16 float values. Stores each value into the 'matrix' array consecutively.

Member Function Documentation

◆ Add()

void Ult::Matrix4x4::Add ( const Matrix4x4 & m1,
const Matrix4x4 & m2 )

Adds m1 and m2 element-wise and stores the result in this matrix.

◆ CreateViewMatrix()

void Ult::Matrix4x4::CreateViewMatrix ( const Vector3D & pos,
const Vector3D & dir,
const Vector3D & up,
const Vector3D & right )

Make this a view matrix using camera position, forward view direction, and right vector.

◆ Identity()

void Ult::Matrix4x4::Identity ( )

Sets the values of the matrix to an identity matrix.

◆ InverseMatrix()

bool Ult::Matrix4x4::InverseMatrix ( const Matrix4x4 & m)

Attempts to set this matrix as the inverse of m. If fails (determinant of m is 0), sets the matrix to an identity and returns false.

◆ InverseTranslateVector()

Vector3D Ult::Matrix4x4::InverseTranslateVector ( const Vector3D & v) const

Returns this matrix's translation vector minus v.

◆ InvertMatrix()

void Ult::Matrix4x4::InvertMatrix ( const Matrix4x4 & m)

Sets this matrix as the inverse of m. Transposes the rotational component and negates the translation component.

◆ Multiple()

void Ult::Matrix4x4::Multiple ( const Matrix4x4 & m1,
const Matrix4x4 & m2 )

Multiplies m1 and m2 and stores the result in this matrix.

◆ operator*()

Matrix4x4 Ult::Matrix4x4::operator* ( const Matrix4x4 & m) const

Multiplies this matrix and m and returns the result.

◆ operator+()

Matrix4x4 Ult::Matrix4x4::operator+ ( const Matrix4x4 & m) const

Adds this matrix and m element-wise and returns the result.

◆ operator-()

Matrix4x4 Ult::Matrix4x4::operator- ( const Matrix4x4 & m) const

Subtracts this matrix and m element-wise and returns the result.

◆ operator=()

void Ult::Matrix4x4::operator= ( const Matrix4x4 & m)

Sets the values of this matrix equal to the values of m.

◆ Rotate()

void Ult::Matrix4x4::Rotate ( const float angleDegrees,
const int x,
const int y,
const int z )

Make this a rotation matrix using an axis and angle in degrees.

◆ RotateAxis()

void Ult::Matrix4x4::RotateAxis ( const float angleDegrees,
const Vector3D & axis )

Make this a rotation matrix using an axis and angle in degrees.

◆ RotateX()

void Ult::Matrix4x4::RotateX ( const float angleDegrees)

Make this a x-axis rotation matrix using an angle in degrees.

◆ RotateY()

void Ult::Matrix4x4::RotateY ( const float angleDegrees)

Make this a y-axis rotation matrix using an angle in degrees.

◆ RotateZ()

void Ult::Matrix4x4::RotateZ ( const float angleDegrees)

Make this a z-axis rotation matrix using an angle in degrees.

◆ Scale()

void Ult::Matrix4x4::Scale ( const Vector3D & scale)

Sets the scale components (3 main diagonals of the matrix) equal to 'scale'.

◆ SetRotationRadians()

void Ult::Matrix4x4::SetRotationRadians ( const float x,
const float y,
const float z )

Make this a rotation matrix using 3 radian euler angles for x,y,z.

◆ Subtract()

void Ult::Matrix4x4::Subtract ( const Matrix4x4 & m1,
const Matrix4x4 & m2 )

Subtracts m1 and m2 element-wise and stores the result in this matrix.

◆ Translate() [1/2]

void Ult::Matrix4x4::Translate ( const float x,
const float y,
const float z )

Sets elements 12,13,14 to x,y,z and element 15 to 1.

◆ Translate() [2/2]

void Ult::Matrix4x4::Translate ( const Vector3D & v)

Sets elements 12,13,14 to v and element 15 to 1.

◆ Transpose()

void Ult::Matrix4x4::Transpose ( const Matrix4x4 & m)

Sets the values of this matrix as the transpose of m.

◆ VectorMatrixMultiply()

Vector3D Ult::Matrix4x4::VectorMatrixMultiply ( const Vector3D & v) const

Returns the multiplication of the matrix and v, assuming a w component of 1.

◆ VectorMatrixMultiply3x3()

Vector3D Ult::Matrix4x4::VectorMatrixMultiply3x3 ( const Vector3D & v) const

Returns the multiplication of the 3x3 rotational component of the matrix and v.

◆ VectorMatrixMultiply3x3Inv()

Vector3D Ult::Matrix4x4::VectorMatrixMultiply3x3Inv ( const Vector3D & v) const

Returns the multiplication of the 3x3 rotational component transpose of the matrix and v.

◆ Zero()

void Ult::Matrix4x4::Zero ( )

Sets the values of the matrix to all zeros.

Member Data Documentation

◆ matrix

float Ult::Matrix4x4::matrix[16]

The 16 matrix values.


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