matrix3_ptr.c file
Functions
- void mat3_identity_ptr(matrix3* res)
- Initializes the 3x3 matrix to identity (diagonal 1.0, others 0.0).
- void mat3_mul_ptr(matrix3* res, const matrix3* a, const matrix3* b)
- Multiplies two 3x3 matrices (a * b) in column-major / column-vector convention.
- void mat3_transpose_ptr(matrix3* res, const matrix3* m)
- Computes the transpose of the input 3x3 matrix and stores in res.
- void mat3_inverse_ptr(matrix3* res, const matrix3* m)
- Computes the inverse of the input 3x3 matrix using the adjugate method and stores in res.
-
void mat3_rotation_z_ptr(matrix3* res,
const vm_
float_ t radians) - Sets the 3x3 matrix to a Z-axis rotation by the given angle in radians.
-
void mat3_rotation_z_deg_ptr(matrix3* res,
const vm_
float_ t degrees) - Initializes the 3x3 matrix to a rotation around the Z axis.
-
void mat3_rotation_x_ptr(matrix3* res,
const vm_
float_ t radians) - Sets the 3x3 matrix to a rotation around the X axis.
-
void mat3_rotation_x_deg_ptr(matrix3* res,
const vm_
float_ t degrees) - Initializes the 3x3 matrix to a rotation around the X axis.
-
void mat3_rotation_y_ptr(matrix3* res,
const vm_
float_ t radians) - Sets the 3x3 matrix to a rotation around the Y axis.
-
void mat3_rotation_y_deg_ptr(matrix3* res,
const vm_
float_ t degrees) - Initializes the 3x3 matrix to a rotation around the Y axis.
- void mat3_translate_ptr(matrix3* res, const vector2* t)
- Builds a 3x3 2D translation matrix.
- void mat3_scale_ptr(matrix3* res, const vector2* s)
- Builds a 3x3 2D scaling matrix.
- void mat3_from_mat4_ptr(matrix3* res, const matrix4* m)
- Copies the upper-left 3x3 of a matrix4.
- void mat3_normal_ptr(matrix3* res, const matrix3* m)
- Inverse-transpose of a 3x3, for transforming normals.
- void mat3_mul_vec3_ptr(vector3* res, const matrix3* m, const vector3* v)
- Multiplies a 3x3 matrix by a vector3.
- void mat3_mul_vec2_ptr(vector2* res, const matrix3* m, const vector2* v)
- Applies a 3x3 affine transform to a vector2.
-
static void vm_mat3_jacobi_rotate(matrix3* a,
matrix3* v,
const int p,
const int q,
const vm_
float_ t tol) - Performs one Jacobi rotation step for symmetric matrix eigenvalue decomposition.
- void mat3_sym_eigen_ptr(vector3* eigenvalues, matrix3* axes, const matrix3* m)
- Jacobi eigensolve of a symmetric 3x3 matrix.
Function documentation
void mat3_identity_ptr(matrix3* res)
Initializes the 3x3 matrix to identity (diagonal 1.0, others 0.0).
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
void mat3_mul_ptr(matrix3* res, const matrix3* a, const matrix3* b)
Multiplies two 3x3 matrices (a * b) in column-major / column-vector convention.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| a | Pointer to the first matrix. |
| b | Pointer to the second matrix. |
Accumulates into a temporary matrix.
void mat3_transpose_ptr(matrix3* res, const matrix3* m)
Computes the transpose of the input 3x3 matrix and stores in res.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| m | Pointer to the input matrix. |
void mat3_inverse_ptr(matrix3* res, const matrix3* m)
Computes the inverse of the input 3x3 matrix using the adjugate method and stores in res.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| m | Pointer to the input matrix. |
If the determinant is zero, sets res to identity.
void mat3_rotation_z_ptr(matrix3* res,
const vm_ float_ t radians)
Sets the 3x3 matrix to a Z-axis rotation by the given angle in radians.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| radians | Rotation angle in radians. |
void mat3_rotation_z_deg_ptr(matrix3* res,
const vm_ float_ t degrees)
Initializes the 3x3 matrix to a rotation around the Z axis.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| degrees | Rotation angle in degrees. |
void mat3_rotation_x_ptr(matrix3* res,
const vm_ float_ t radians)
Sets the 3x3 matrix to a rotation around the X axis.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| radians | Rotation angle in radians. |
void mat3_rotation_x_deg_ptr(matrix3* res,
const vm_ float_ t degrees)
Initializes the 3x3 matrix to a rotation around the X axis.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| degrees | Rotation angle in degrees. |
void mat3_rotation_y_ptr(matrix3* res,
const vm_ float_ t radians)
Sets the 3x3 matrix to a rotation around the Y axis.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| radians | Rotation angle in radians. |
void mat3_rotation_y_deg_ptr(matrix3* res,
const vm_ float_ t degrees)
Initializes the 3x3 matrix to a rotation around the Y axis.
| Parameters | |
|---|---|
| res | Pointer to the output matrix3. |
| degrees | Rotation angle in degrees. |
void mat3_translate_ptr(matrix3* res, const vector2* t)
Builds a 3x3 2D translation matrix.
| Parameters | |
|---|---|
| res | Output value. |
| t | Translation vector. |
void mat3_scale_ptr(matrix3* res, const vector2* s)
Builds a 3x3 2D scaling matrix.
| Parameters | |
|---|---|
| res | Output value. |
| s | Scale vector. |
void mat3_from_mat4_ptr(matrix3* res, const matrix4* m)
Copies the upper-left 3x3 of a matrix4.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
void mat3_normal_ptr(matrix3* res, const matrix3* m)
Inverse-transpose of a 3x3, for transforming normals.
| Parameters | |
|---|---|
| res | Normal matrix. |
| m | Linear part of a model transform. |
If m is singular the result is identity.
void mat3_mul_vec3_ptr(vector3* res, const matrix3* m, const vector3* v)
Multiplies a 3x3 matrix by a vector3.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
| v | Input vector. |
void mat3_mul_vec2_ptr(vector2* res, const matrix3* m, const vector2* v)
Applies a 3x3 affine transform to a vector2.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
| v | Input vector. |
static void vm_mat3_jacobi_rotate(matrix3* a,
matrix3* v,
const int p,
const int q,
const vm_ float_ t tol)
Performs one Jacobi rotation step for symmetric matrix eigenvalue decomposition.
| Parameters | |
|---|---|
| a | Pointer to the symmetric matrix being diagonalized (modified in-place). |
| v | Pointer to the matrix of accumulated eigenvectors (modified in-place). |
| p | First rotation index (0-2). |
| q | Second rotation index (0-2). |
| tol | Threshold below which the off-diagonal element is considered zero. |
Rotates the matrix a to eliminate the off-diagonal element at (p,q) using a Givens rotation if its magnitude exceeds the given tolerance. The accumulated eigenvectors in v are updated with the same rotation.
void mat3_sym_eigen_ptr(vector3* eigenvalues, matrix3* axes, const matrix3* m)
Jacobi eigensolve of a symmetric 3x3 matrix.
| Parameters | |
|---|---|
| eigenvalues | Output eigenvalues. |
| axes | Output eigenvector columns. |
| m | Input matrix (copied and symmetrized). |
m is first replaced by (m + m^T) / 2. Eigenvalues are the diagonal of the rotated matrix; eigenvector i is column i of axes.