High-performance 3x3 matrix implementation optimized for Saturn hardware.
The Matrix33 class provides a comprehensive set of matrix operations optimized for 3D transformations, rotations, and linear algebra calculations on Saturn hardware. It uses fixed-point arithmetic for all operations to ensure consistent behavior across platforms and maximize performance.
Key features:
Matrix layout:
| Row0.x Row0.y Row0.z | | Row1.x Row1.y Row1.z | | Row2.x Row2.y Row2.z |
Where:
Common applications:
Performance considerations:
Implementation notes:
#include <mat33.hpp>
Public Member Functions | |
constexpr | Matrix33 () |
Default constructor initializing to a zero matrix. | |
constexpr | Matrix33 (const Vector3D &row0In, const Vector3D &row1In, const Vector3D &row2In) |
Creates matrix from individual row vectors. | |
constexpr | Matrix33 (const Vector3D &up, const Vector3D &direction) |
Creates rotation matrix from up and direction vectors. | |
constexpr Fxp | Determinant () const |
Calculate the determinant of the matrix. | |
constexpr Matrix33 | operator* (const Matrix33 &other) const |
Create a new matrix as the product of this and another matrix. | |
constexpr Vector3D | operator* (const Vector3D &v) const |
Transform a vector by this matrix. | |
constexpr Matrix33 & | operator*= (const Matrix33 &other) |
Multiply this matrix by another matrix in-place. | |
constexpr Matrix33 & | RotateX (const Angle &angleX) |
Apply X-axis rotation to the current matrix. | |
constexpr Matrix33 & | RotateY (const Angle &angleY) |
Apply Y-axis rotation to the current matrix. | |
constexpr Matrix33 & | RotateZ (const Angle &angleZ) |
Apply Z-axis rotation to the current matrix. | |
constexpr Matrix33 & | Scale (const Vector3D &scale) |
Scale the matrix in-place along each axis. | |
constexpr Matrix33 & | Transpose () |
Transpose the matrix in-place. | |
bool constexpr | TryInverse (Matrix33 &out) const |
Attempt to compute the inverse of the matrix. | |
Static Public Member Functions | |
static constexpr Matrix33 | CreateRotation (const Angle &angleX, const Angle &angleY, const Angle &angleZ) |
Create a rotation matrix from Euler angles. | |
static constexpr Matrix33 | CreateRotationX (const Angle &angle) |
Create a new X-axis rotation matrix. | |
static constexpr Matrix33 | CreateRotationY (const Angle &angle) |
Create a new Y-axis rotation matrix. | |
static constexpr Matrix33 | CreateRotationZ (const Angle &angle) |
Create a new Z-axis rotation matrix. | |
static constexpr Matrix33 | CreateScale (const Vector3D &scale) |
Create a scale matrix. | |
static consteval Matrix33 | Identity () |
Create an identity matrix. | |
Public Attributes | |
Vector3D | Row0 |
Vector3D | Row1 |
Vector3D | Row2 |