Matrix3
This class represents a 3×3 matrix stored in column-major order, consistent with the rest of the math module. It is commonly used for linear transforms such as rotation, scaling, or for extracting the upper-left 3×3 portion of a Matrix4. The class supports construction from individual components, vectors, or a full 4×4 matrix, as well as element access and comparison.
Construction
Constructors
Matrix3() constexpr
Extracts the upper-left 3×3 block from a 4×4 matrix.
Matrix3::Matrix3(const Matrix4& mat);| Parameter | Description |
|---|---|
| mat | Source matrix. |
Matrix3() constexpr
Constructs a matrix from three column vectors.
Matrix3::Matrix3(const Vector3& vec0, const Vector3& vec1, const Vector3& vec2);| Parameter | Description |
|---|---|
| vec0 | |
| vec1 | First column. |
| vec2 | Second column. |
Matrix3() constexpr
Constructs a matrix from individual components (row-major).
Matrix3::Matrix3(float n00, float n01, float n02, float n10, float n11, float n12, float n20, float n21, float n22);| Parameter | Description |
|---|---|
| n00 | First row, first element. |
| n01 | First row, second element. |
| n02 | First row, third element. |
| n10 | Second row, first element. |
| n11 | Second row, second element. |
| n12 | Second row, third element. |
| n20 | Third row, first element. |
| n21 | Third row, second element. |
| n22 | Third row, third element. |
Matrix3() constexpr
Constructs a diagonal matrix.
Matrix3::Matrix3(float value);| Parameter | Description |
|---|---|
| value | Value to place on the diagonal. |
Functions
operator()() float &
Accesses an element by (row, column).
float& Matrix3::operator()(int row, int col);| Parameter | Description |
|---|---|
| row | Row index. |
| col | Column index. |
operator()() const float
Accesses an element by (row, column).
const float Matrix3::operator()(int row, int col) const;| Parameter | Description |
|---|---|
| row | Row index. |
| col | Column index. |
Accesses a column vector.
Vector3& Matrix3::operator[](int col);| Parameter | Description |
|---|---|
| col | Column index. |
Accesses a column vector.
const Vector3& Matrix3::operator[](int col) const;| Parameter | Description |
|---|---|
| col | Column index. |
Returns the identity matrix.
static constexpr Matrix3 Matrix3::Identity();Determinant() float
Computes the determinant of a 3×3 matrix.
float Determinant(const Matrix3& mat);| Parameter | Description |
|---|---|
| mat | Input matrix. |
Computes the inverse of a 3×3 matrix.
Matrix3 Inverse(const Matrix3& mat);| Parameter | Description |
|---|---|
| mat | Input matrix. |
Multiplies two 3×3 matrices.
Matrix3 operator* (const Matrix3& a, const Matrix3& b);| Parameter | Description |
|---|---|
| a | Left matrix. |
| b | Right matrix. |
Multiplies a matrix by a vector.
Vector3 operator* (const Matrix3& mat, const Vector3& vec);| Parameter | Description |
|---|---|
| mat | Input matrix. |
| vec | Input vector. |