Matrix4 represents a 4x4 matrix used for transformations in 3D space. It supports various operations such as matrix multiplication, inversion, and extracting different transformation components (e.g., translation, rotation, scale). This matrix can also be constructed for specific transformations like scaling, rotating, and translating, as well as for creating projection matrices for rendering.
More...
#include <Matrix4.h>
|
| Matrix4 () |
| Default constructor for Matrix4. Initializes the matrix as an identity matrix by default.
|
|
| Matrix4 (float inMat[4][4]) |
| Constructor that initializes the matrix with a 4x4 float array.
|
|
const float * | GetAsFloatPtr () const |
| Returns the matrix as a const float pointer for direct access to the raw data.
|
|
Matrix4 & | operator*= (const Matrix4 &right) |
| Multiplies the current matrix by another matrix (a * b).
|
|
void | Invert () |
| Inverts the matrix (calculates its inverse). This operation is computationally expensive and should be used carefully.
|
|
Vector3 | GetTranslation () const |
| Extracts the translation vector from the matrix (the position).
|
|
Vector3 | GetXAxis () const |
| Extracts the X-axis direction vector from the matrix (usually for orientation).
|
|
Vector3 | GetYAxis () const |
| Extracts the Y-axis direction vector from the matrix (usually for orientation).
|
|
Vector3 | GetZAxis () const |
| Extracts the Z-axis direction vector from the matrix (usually for orientation).
|
|
Vector3 | GetScale () const |
| Extracts the scaling factors from the matrix (how much the object is scaled along each axis).
|
|
|
static Matrix4 | CreateScale (float xScale, float yScale, float zScale) |
| Creates a scaling matrix using individual scale factors for each axis.
|
|
static Matrix4 | CreateScale (const Vector3 &scaleVector) |
| Creates a scaling matrix using a Vector3 to specify the scale for each axis.
|
|
static Matrix4 | CreateScale (float scale) |
| Creates a uniform scaling matrix where all axes are scaled by the same factor.
|
|
static Matrix4 | CreateRotationX (float theta) |
| Creates a rotation matrix for rotation around the X-axis.
|
|
static Matrix4 | CreateRotationY (float theta) |
| Creates a rotation matrix for rotation around the Y-axis.
|
|
static Matrix4 | CreateRotationZ (float theta) |
| Creates a rotation matrix for rotation around the Z-axis.
|
|
static Matrix4 | CreateTranslation (const Vector3 &trans) |
| Creates a translation matrix that moves an object by a given translation vector.
|
|
static Matrix4 | CreateSimpleViewProj (float width, float height) |
| Creates a simple orthogonal view projection matrix. Typically used for 2D rendering or simple orthographic projections.
|
|
static Matrix4 | CreateFromQuaternion (const Quaternion &q) |
| Creates a rotation matrix from a quaternion representation.
|
|
static Matrix4 | CreateLookAt (const Vector3 &eye, const Vector3 &target, const Vector3 &up) |
| Creates a "look-at" matrix for setting up camera orientation.
|
|
static Matrix4 | CreateOrtho (float width, float height, float near, float far) |
| Creates an orthographic projection matrix (used for 2D rendering).
|
|
static Matrix4 | CreatePerspectiveFOV (float fovY, float width, float height, float near, float far) |
| Creates a perspective projection matrix with a specified field of view.
|
|
static Matrix4 | CreatePerspective (float left, float right, float bottom, float top, float near, float far) |
| Creates a perspective projection matrix with specified frustum values.
|
|
|
static const Matrix4 | Identity |
| Constant for the identity matrix (no transformation)
|
|
Matrix4 represents a 4x4 matrix used for transformations in 3D space. It supports various operations such as matrix multiplication, inversion, and extracting different transformation components (e.g., translation, rotation, scale). This matrix can also be constructed for specific transformations like scaling, rotating, and translating, as well as for creating projection matrices for rendering.
◆ Matrix4() [1/2]
Default constructor for Matrix4. Initializes the matrix as an identity matrix by default.
◆ Matrix4() [2/2]
Matrix4::Matrix4 |
( |
float | inMat[4][4] | ) |
|
|
explicit |
Constructor that initializes the matrix with a 4x4 float array.
- Parameters
-
inMat | A 4x4 matrix to initialize the object with. |
◆ CreateFromQuaternion()
Creates a rotation matrix from a quaternion representation.
- Parameters
-
q | The quaternion to convert to a matrix. |
- Returns
- A new Matrix4 representing the rotation described by the quaternion.
◆ CreateLookAt()
Creates a "look-at" matrix for setting up camera orientation.
- Parameters
-
eye | The position of the camera. |
target | The point the camera is looking at. |
up | The "up" vector that defines the orientation of the camera. |
- Returns
- A new Matrix4 representing the view transformation for the camera.
◆ CreateOrtho()
Matrix4 Matrix4::CreateOrtho |
( |
float | width, |
|
|
float | height, |
|
|
float | near, |
|
|
float | far ) |
|
static |
Creates an orthographic projection matrix (used for 2D rendering).
- Parameters
-
width | The width of the view frustum. |
height | The height of the view frustum. |
near | The near clipping plane. |
far | The far clipping plane. |
- Returns
- A new Matrix4 representing the orthographic projection transformation.
◆ CreatePerspective()
Matrix4 Matrix4::CreatePerspective |
( |
float | left, |
|
|
float | right, |
|
|
float | bottom, |
|
|
float | top, |
|
|
float | near, |
|
|
float | far ) |
|
static |
Creates a perspective projection matrix with specified frustum values.
- Parameters
-
left | The left boundary of the near plane. |
right | The right boundary of the near plane. |
bottom | The bottom boundary of the near plane. |
top | The top boundary of the near plane. |
near | The near clipping plane. |
far | The far clipping plane. |
- Returns
- A new Matrix4 representing the perspective projection transformation.
◆ CreatePerspectiveFOV()
Matrix4 Matrix4::CreatePerspectiveFOV |
( |
float | fovY, |
|
|
float | width, |
|
|
float | height, |
|
|
float | near, |
|
|
float | far ) |
|
static |
Creates a perspective projection matrix with a specified field of view.
- Parameters
-
fovY | The vertical field of view (in radians). |
width | The width of the viewport. |
height | The height of the viewport. |
near | The near clipping plane. |
far | The far clipping plane. |
- Returns
- A new Matrix4 representing the perspective projection transformation.
◆ CreateRotationX()
Matrix4 Matrix4::CreateRotationX |
( |
float | theta | ) |
|
|
static |
Creates a rotation matrix for rotation around the X-axis.
- Parameters
-
theta | The angle (in radians) to rotate around the X-axis. |
- Returns
- A new Matrix4 representing the rotation transformation.
◆ CreateRotationY()
Matrix4 Matrix4::CreateRotationY |
( |
float | theta | ) |
|
|
static |
Creates a rotation matrix for rotation around the Y-axis.
- Parameters
-
theta | The angle (in radians) to rotate around the Y-axis. |
- Returns
- A new Matrix4 representing the rotation transformation.
◆ CreateRotationZ()
Matrix4 Matrix4::CreateRotationZ |
( |
float | theta | ) |
|
|
static |
Creates a rotation matrix for rotation around the Z-axis.
- Parameters
-
theta | The angle (in radians) to rotate around the Z-axis. |
- Returns
- A new Matrix4 representing the rotation transformation.
◆ CreateScale() [1/3]
Creates a scaling matrix using a Vector3 to specify the scale for each axis.
- Parameters
-
scaleVector | The scaling vector containing the scale for X, Y, and Z axes. |
- Returns
- A new Matrix4 representing the scaling transformation.
◆ CreateScale() [2/3]
Matrix4 Matrix4::CreateScale |
( |
float | scale | ) |
|
|
static |
Creates a uniform scaling matrix where all axes are scaled by the same factor.
- Parameters
-
scale | The uniform scaling factor. |
- Returns
- A new Matrix4 representing the uniform scaling transformation.
◆ CreateScale() [3/3]
Matrix4 Matrix4::CreateScale |
( |
float | xScale, |
|
|
float | yScale, |
|
|
float | zScale ) |
|
static |
Creates a scaling matrix using individual scale factors for each axis.
- Parameters
-
xScale | The scale factor along the X-axis. |
yScale | The scale factor along the Y-axis. |
zScale | The scale factor along the Z-axis. |
- Returns
- A new Matrix4 representing the scaling transformation.
◆ CreateSimpleViewProj()
Matrix4 Matrix4::CreateSimpleViewProj |
( |
float | width, |
|
|
float | height ) |
|
static |
Creates a simple orthogonal view projection matrix. Typically used for 2D rendering or simple orthographic projections.
- Parameters
-
width | The width of the viewport or projection. |
height | The height of the viewport or projection. |
- Returns
- A new Matrix4 representing a simple orthogonal projection.
◆ CreateTranslation()
Creates a translation matrix that moves an object by a given translation vector.
- Parameters
-
trans | The translation vector to apply to the object. |
- Returns
- A new Matrix4 representing the translation transformation.
◆ GetAsFloatPtr()
const float * Matrix4::GetAsFloatPtr |
( |
| ) |
const |
Returns the matrix as a const float pointer for direct access to the raw data.
- Returns
- A pointer to the raw float data of the matrix.
◆ GetScale()
Vector3 Matrix4::GetScale |
( |
| ) |
const |
Extracts the scaling factors from the matrix (how much the object is scaled along each axis).
- Returns
- A Vector3 representing the scale along each axis.
◆ GetTranslation()
Vector3 Matrix4::GetTranslation |
( |
| ) |
const |
Extracts the translation vector from the matrix (the position).
- Returns
- A Vector3 representing the translation part of the matrix.
◆ GetXAxis()
Vector3 Matrix4::GetXAxis |
( |
| ) |
const |
Extracts the X-axis direction vector from the matrix (usually for orientation).
- Returns
- A normalized Vector3 representing the X-axis.
◆ GetYAxis()
Vector3 Matrix4::GetYAxis |
( |
| ) |
const |
Extracts the Y-axis direction vector from the matrix (usually for orientation).
- Returns
- A normalized Vector3 representing the Y-axis.
◆ GetZAxis()
Vector3 Matrix4::GetZAxis |
( |
| ) |
const |
Extracts the Z-axis direction vector from the matrix (usually for orientation).
- Returns
- A normalized Vector3 representing the Z-axis.
◆ Invert()
Inverts the matrix (calculates its inverse). This operation is computationally expensive and should be used carefully.
◆ operator*=()
Multiplies the current matrix by another matrix (a * b).
- Parameters
-
right | The matrix to multiply the current matrix by. |
- Returns
- The updated matrix.
◆ operator*
Multiplies two matrices and returns the resulting matrix.
- Parameters
-
a | The first matrix. |
b | The second matrix. |
- Returns
- The result of multiplying matrix a with matrix b.
◆ Identity
Constant for the identity matrix (no transformation)
◆ mat
The documentation for this class was generated from the following files: