mat.h file
Fixed-size matrices.
Products are column-major AB with the column vector on the right. A by-value matrix4 copies 64 bytes (f32) or 128 bytes (f64); hot loops should use _ptr.
Functions
- auto mat2_identity(void) -> matrix2
- Constructs the 2x2 identity matrix.
- auto mat2_mul(matrix2 a, matrix2 b) -> matrix2
- Multiplies two 2x2 matrices (a * b).
- auto mat2_transpose(matrix2 m) -> matrix2
- Computes the transpose of a 2x2 matrix.
- auto mat2_inverse(matrix2 m) -> matrix2
- Computes the inverse of a 2x2 matrix.
-
auto mat2_rotation_z(vm_
float_ t radians) -> matrix2 - Constructs a 2x2 rotation matrix around the Z axis.
-
auto mat2_rotation_z_deg(vm_
float_ t degrees) -> matrix2 - Constructs a 2x2 rotation matrix from an angle in degrees around the Z axis.
- auto mat2_scale(vector2 s) -> matrix2
- Builds a 2x2 scaling matrix from a vector2.
- auto mat2_from_mat3(matrix3 m) -> matrix2
- Copies the upper-left 2x2 of a matrix3.
- auto mat2_mul_vec2(matrix2 m, vector2 v) -> vector2
- Multiplies a 2x2 matrix by a vector2.
-
auto mat2_determinant(matrix2 m) -> vm_
float_ t - Calculates the determinant of the given 2x2 matrix.
- auto mat3_identity(void) -> matrix3
- Constructs the 3x3 identity matrix.
- auto mat3_mul(matrix3 a, matrix3 b) -> matrix3
- Multiplies two 3x3 matrices.
- auto mat3_transpose(matrix3 m) -> matrix3
- Computes the transpose of a 3x3 matrix.
- auto mat3_inverse(matrix3 m) -> matrix3
- Computes the inverse of a 3x3 matrix.
- auto mat3_inverse_ok(matrix3* res, const matrix3* m) -> bool
- Inverse of a 3×3 with an
okflag. - auto mat3_polar(matrix3* R, matrix3* U, const matrix3* F) -> bool
- Polar decomposition
F = R U. -
auto mat3_rotation_x(vm_
float_ t radians) -> matrix3 - Constructs a 3x3 rotation matrix around the X axis.
-
auto mat3_rotation_y(vm_
float_ t radians) -> matrix3 - Constructs a 3x3 rotation matrix around the Y axis.
-
auto mat3_rotation_z(vm_
float_ t radians) -> matrix3 - Constructs a 3x3 rotation matrix around the Z axis.
-
auto mat3_rotation_x_deg(vm_
float_ t degrees) -> matrix3 - Constructs a 3x3 rotation matrix around the X axis.
-
auto mat3_rotation_y_deg(vm_
float_ t degrees) -> matrix3 - 3x3 rotation about Y from an angle in degrees.
-
auto mat3_rotation_z_deg(vm_
float_ t degrees) -> matrix3 - Constructs a 3x3 rotation matrix around the Z axis.
- auto mat3_translate(vector2 t) -> matrix3
- Builds a 3x3 2D translation matrix.
- auto mat3_scale(vector2 s) -> matrix3
- Builds a 3x3 2D scaling matrix.
- auto mat3_normal(matrix3 m) -> matrix3
- Inverse-transpose of a 3x3 (normal matrix).
- auto mat3_from_mat4(matrix4 m) -> matrix3
- Copies the upper-left 3x3 of a matrix4.
- auto mat3_mul_vec3(matrix3 m, vector3 v) -> vector3
- Multiplies a 3x3 matrix by a vector3.
- auto mat3_sym_eigen(matrix3 m, matrix3* axes) -> vector3
- Analytical eigenvalues of a symmetric 3×3, sorted ascending.
- auto mat3_mul_vec2(matrix3 m, vector2 v) -> vector2
- Applies a 3x3 affine transform to a vector2.
-
auto mat3_determinant(matrix3 m) -> vm_
float_ t - Computes the determinant of a 3x3 matrix.
- auto mat4_identity(void) -> matrix4
- Constructs the 4x4 identity matrix.
- auto mat4_mul(matrix4 a, matrix4 b) -> matrix4
- Multiplies two 4x4 matrices (a * b).
- auto mat4_transpose(matrix4 m) -> matrix4
- Computes the transpose of a 4x4 matrix.
- auto mat4_inverse(matrix4 m) -> matrix4
- Computes the inverse of a 4x4 matrix.
- auto mat4_inverse_affine(matrix4 m) -> matrix4
- Inverse of an affine matrix
[R t; 0 1]. - auto mat4_translate(vector3 v) -> matrix4
- Constructs a translation matrix from the given vector.
- auto mat4_scale(vector3 v) -> matrix4
- Constructs a scaling matrix from the given scale vector.
- auto mat4_normal(matrix4 m) -> matrix4
- Inverse-transpose of the upper 3x3, embedded in a matrix4.
-
auto mat4_rotation(vector3 axis,
vm_
float_ t radians) -> matrix4 - Constructs a 4x4 rotation matrix.
-
auto mat4_rotation_x(vm_
float_ t radians) -> matrix4 - Constructs a 4x4 rotation matrix around the X axis.
-
auto mat4_rotation_y(vm_
float_ t radians) -> matrix4 - Constructs a 4x4 rotation matrix around the Y axis.
-
auto mat4_rotation_z(vm_
float_ t radians) -> matrix4 - Constructs a 4x4 rotation matrix around the Z axis.
-
auto mat4_rotation_deg(vector3 axis,
vm_
float_ t degrees) -> matrix4 - Constructs a 4x4 rotation matrix from an axis and angle in degrees.
-
auto mat4_rotation_x_deg(vm_
float_ t degrees) -> matrix4 - Constructs a 4x4 rotation matrix around the X axis.
-
auto mat4_rotation_y_deg(vm_
float_ t degrees) -> matrix4 - Constructs a 4x4 rotation matrix around the Y axis.
-
auto mat4_rotation_z_deg(vm_
float_ t degrees) -> matrix4 - Constructs a 4x4 rotation matrix around the Z axis from an angle in degrees.
- auto mat4_trs(vector3 translation, quaternion rotation, vector3 scale) -> matrix4
- Builds a 4x4 TRS matrix from translation, rotation, and scale.
- auto mat4_from_mat3(matrix3 m) -> matrix4
- Embeds a matrix3 into the upper-left of a matrix4.
-
auto mat4_determinant(matrix4 m) -> vm_
float_ t - Calculates the determinant of the given 4x4 matrix.
- auto mat4_extract_translation(matrix4 m) -> vector3
- Extracts the translation vector from a matrix4.
- auto mat4_extract_scale(matrix4 m) -> vector3
- Extracts the scale vector from a matrix4.
-
auto mat4_mul_vec3(matrix4 m,
vector3 v,
vm_
float_ t w) -> vector3 - Transforms a vector3 by a 4x4 matrix using homogeneous w.
- auto mat4_mul_vec4(matrix4 m, vector4 v) -> vector4
- Multiplies a 4x4 matrix by a vector4.
- auto mat4_extract_rotation(matrix4 m) -> quaternion
- Extracts the rotation quaternion from a matrix4.
- void mat2_identity_ptr(matrix2* res)
- Initializes the 2x2 matrix to identity (diagonal 1.0, others 0.0).
- void mat2_mul_ptr(matrix2* res, const matrix2* a, const matrix2* b)
- Multiplies two 2x2 matrices (a * b) in column-major / column-vector convention.
- void mat2_transpose_ptr(matrix2* res, const matrix2* m)
- Computes the transpose of the input 2x2 matrix and stores in res.
- void mat2_inverse_ptr(matrix2* res, const matrix2* m)
- Computes the inverse of the input 2x2 matrix using determinant and stores in res.
-
void mat2_rotation_z_ptr(matrix2* res,
vm_
float_ t radians) - Sets the 2x2 matrix to a Z-axis (counter-clockwise) rotation.
-
void mat2_rotation_z_deg_ptr(matrix2* res,
vm_
float_ t degrees) - Initializes the 2x2 matrix to a rotation around Z axis (counter-clockwise).
- void mat2_scale_ptr(matrix2* res, const vector2* s)
- Builds a 2x2 scaling matrix from a vector2.
- void mat2_from_mat3_ptr(matrix2* res, const matrix3* m)
- Copies the upper-left 2x2 of a matrix3.
- void mat2_mul_vec2_ptr(vector2* res, const matrix2* m, const vector2* v)
- Multiplies a 2x2 matrix by a vector2.
- 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_x_ptr(matrix3* res,
vm_
float_ t radians) - Sets the 3x3 matrix to a rotation around the X axis.
-
void mat3_rotation_y_ptr(matrix3* res,
vm_
float_ t radians) - Sets the 3x3 matrix to a rotation around the Y axis.
-
void mat3_rotation_z_ptr(matrix3* res,
vm_
float_ t radians) - Sets the 3x3 matrix to a Z-axis rotation by the given angle in radians.
-
void mat3_rotation_x_deg_ptr(matrix3* res,
vm_
float_ t degrees) - Initializes the 3x3 matrix to a rotation around the X axis.
-
void mat3_rotation_y_deg_ptr(matrix3* res,
vm_
float_ t degrees) - Initializes the 3x3 matrix to a rotation around the Y axis.
-
void mat3_rotation_z_deg_ptr(matrix3* res,
vm_
float_ t degrees) - Initializes the 3x3 matrix to a rotation around the Z 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.
- void mat3_sym_eigen_ptr(vector3* eigenvalues, matrix3* axes, const matrix3* m)
- Analytical eigensolve of a symmetric 3x3 matrix.
- void mat4_identity_ptr(matrix4* res)
- Sets the matrix to the identity matrix.
- void mat4_mul_ptr(matrix4* res, const matrix4* a, const matrix4* b)
- Multiplies two 4x4 matrices (dispatched).
- void mat4_transpose_ptr(matrix4* res, const matrix4* m)
- Transposes a 4x4 matrix (dispatched).
- void mat4_inverse_ptr(matrix4* res, const matrix4* m)
- Computes the inverse of a 4x4 matrix.
- void mat4_inverse_affine_ptr(matrix4* res, const matrix4* m)
- Inverse of an affine matrix
[R t; 0 1]. - void mat4_translate_ptr(matrix4* res, const vector3* v)
- Sets the matrix to a translation matrix.
- void mat4_scale_ptr(matrix4* res, const vector3* v)
- Sets the matrix to a scaling matrix using the provided scale vector.
- void mat4_normal_ptr(matrix4* res, const matrix4* m)
- Inverse-transpose of the upper-left 3x3, embedded in a matrix4.
-
void mat4_rotation_ptr(matrix4* res,
const vector3* axis,
vm_
float_ t radians) - Sets the matrix to a rotation matrix around the given axis.
-
void mat4_rotation_x_ptr(matrix4* res,
vm_
float_ t radians) - Builds a 4x4 rotation matrix around the X axis (radians).
-
void mat4_rotation_y_ptr(matrix4* res,
vm_
float_ t radians) - Sets the matrix to a rotation matrix around the Y axis.
-
void mat4_rotation_z_ptr(matrix4* res,
vm_
float_ t radians) - Sets the matrix to a rotation around the Z axis.
-
void mat4_rotation_deg_ptr(matrix4* res,
const vector3* axis,
vm_
float_ t degrees) - Sets the matrix to a rotation matrix using an axis and angle in degrees.
-
void mat4_rotation_x_deg_ptr(matrix4* res,
vm_
float_ t degrees) - Builds a 4x4 rotation matrix around the X axis (degrees).
-
void mat4_rotation_y_deg_ptr(matrix4* res,
vm_
float_ t degrees) - Builds a 4x4 rotation matrix around the Y axis (degrees).
-
void mat4_rotation_z_deg_ptr(matrix4* res,
vm_
float_ t degrees) - Builds a 4x4 rotation matrix around the Z axis (degrees).
- void mat4_trs_ptr(matrix4* res, const vector3* translation, const quaternion* rotation, const vector3* scale)
- Builds a 4x4 TRS matrix from translation, rotation, and scale.
- void mat4_from_mat3_ptr(matrix4* res, const matrix3* m)
- Embeds a matrix3 into the upper-left of a matrix4.
- void mat4_extract_translation_ptr(vector3* res, const matrix4* m)
- Extracts the translation vector from a matrix4.
- void mat4_extract_scale_ptr(vector3* res, const matrix4* m)
- Extracts the scale vector from a matrix4.
- void mat4_extract_rotation_ptr(quaternion* res, const matrix4* m)
- Extracts the rotation quaternion from a matrix4.
- void mat4_mul_vec4_ptr(vector4* res, const matrix4* m, const vector4* v)
- Transforms a vector4 by a 4x4 matrix (dispatched).
-
void mat4_mul_vec3_ptr(vector3* res,
const matrix4* m,
const vector3* v,
vm_
float_ t w) - Transforms a vector3 by a 4x4 matrix using homogeneous w (dispatched).
- auto mat2i_identity(void) -> matrix2i
- Constructs the 2x2 integer identity matrix.
- auto mat2i_mul(matrix2i a, matrix2i b) -> matrix2i
- Multiplies two 2x2 integer matrices (a * b).
- auto mat2i_transpose(matrix2i m) -> matrix2i
- Computes the transpose of a 2x2 integer matrix.
- auto mat2i_inverse(matrix2i m) -> matrix2i
- Computes the inverse of a 2x2 integer matrix.
- auto mat2i_mul_vec2i(matrix2i m, vector2i v) -> vector2i
- Multiplies a 2x2 integer matrix by a vector2i.
-
auto mat2i_determinant(matrix2i m) -> vm_
int_ t - Calculates the determinant of the given 2x2 integer matrix.
- auto mat3i_identity(void) -> matrix3i
- Constructs the 3x3 identity matrix.
- auto mat3i_mul(matrix3i a, matrix3i b) -> matrix3i
- Multiplies two 3x3 integer matrices.
- auto mat3i_transpose(matrix3i m) -> matrix3i
- Computes the transpose of a 3x3 integer matrix.
- auto mat3i_inverse(matrix3i m) -> matrix3i
- Computes the inverse of a 3x3 integer matrix.
- auto mat3i_mul_vec3i(matrix3i m, vector3i v) -> vector3i
- Multiplies a 3x3 integer matrix by a vector3i.
- auto mat3i_mul_vec2i(matrix3i m, vector2i v) -> vector2i
- Applies a 3x3 integer affine transform to a vector2i.
-
auto mat3i_determinant(matrix3i m) -> vm_
int_ t - Computes the determinant of a 3x3 integer matrix.
- auto mat4i_identity(void) -> matrix4i
- Constructs the 4x4 identity matrix.
- auto mat4i_mul(matrix4i a, matrix4i b) -> matrix4i
- Multiplies two 4x4 integer matrices.
- auto mat4i_transpose(matrix4i m) -> matrix4i
- Computes the transpose of a 4x4 integer matrix.
- auto mat4i_inverse(matrix4i m) -> matrix4i
- Computes the inverse of a 4x4 integer matrix.
- auto mat4i_mul_vec4i(matrix4i m, vector4i v) -> vector4i
- Multiplies a 4x4 integer matrix by a vector4i.
-
auto mat4i_mul_vec3i(matrix4i m,
vector3i v,
vm_
int_ t w) -> vector3i - Transforms a vector3i by a 4x4 integer matrix using homogeneous w.
-
auto mat4i_determinant(matrix4i m) -> vm_
int_ t - Computes the determinant of a 4x4 integer matrix (Laplace expansion along first row).
- void mat2i_identity_ptr(matrix2i* res)
- Initializes the integer 2x2 matrix to identity (diagonal 1, others 0).
- void mat2i_mul_ptr(matrix2i* res, const matrix2i* a, const matrix2i* b)
- Multiplies two integer 2x2 matrices (a * b) using explicit loops and stores the result in res.
- void mat2i_transpose_ptr(matrix2i* res, const matrix2i* m)
- Computes the transpose of the input integer 2x2 matrix and stores in res.
- void mat2i_inverse_ptr(matrix2i* res, const matrix2i* m)
- Computes the inverse of the input integer 2x2 matrix and stores in res.
- void mat2i_mul_vec2i_ptr(vector2i* res, const matrix2i* m, const vector2i* v)
- Multiplies a 2x2 integer matrix by a vector2i.
- void mat3i_identity_ptr(matrix3i* res)
- Fills the given 3x3 integer matrix with the identity matrix.
- void mat3i_mul_ptr(matrix3i* res, const matrix3i* a, const matrix3i* b)
- Multiplies two 3x3 integer matrices (standard matrix multiplication).
- void mat3i_transpose_ptr(matrix3i* res, const matrix3i* m)
- Computes the transpose of a 3x3 integer matrix.
- void mat3i_inverse_ptr(matrix3i* res, const matrix3i* m)
- Computes the inverse of a 3x3 integer matrix using adjugate over determinant.
- void mat3i_mul_vec3i_ptr(vector3i* res, const matrix3i* m, const vector3i* v)
- Multiplies a 3x3 integer matrix by a vector3i.
- void mat3i_mul_vec2i_ptr(vector2i* res, const matrix3i* m, const vector2i* v)
- Applies a 3x3 integer affine transform to a vector2i.
- void mat4i_identity_ptr(matrix4i* res)
- Sets the given 4x4 integer matrix to the identity matrix.
- void mat4i_mul_ptr(matrix4i* res, const matrix4i* a, const matrix4i* b)
- Performs matrix multiplication of two 4x4 matrices and stores the result.
- void mat4i_transpose_ptr(matrix4i* res, const matrix4i* m)
- Transposes the given 4x4 integer matrix and stores the result in the provided matrix structure.
- void mat4i_inverse_ptr(matrix4i* res, const matrix4i* m)
- Computes the inverse of the given 4x4 integer matrix and stores the result in the specified matrix.
- void mat4i_mul_vec4i_ptr(vector4i* res, const matrix4i* m, const vector4i* v)
- Multiplies a 4x4 integer matrix by a vector4i.
-
void mat4i_mul_vec3i_ptr(vector3i* res,
const matrix4i* m,
const vector3i* v,
vm_
int_ t w) - Transforms a vector3i by a 4x4 integer matrix using homogeneous w.
- auto mat2_eq(matrix2 a, matrix2 b) -> bool
- Returns true if two matrices are equal within
VECMAT_.EPSILON - auto mat3_eq(matrix3 a, matrix3 b) -> bool
- Returns true if two matrices are equal within
VECMAT_.EPSILON - auto mat4_eq(matrix4 a, matrix4 b) -> bool
- Returns true if two matrices are equal within
VECMAT_.EPSILON - auto mat2i_eq(matrix2i a, matrix2i b) -> bool
- Returns true if two matrices are exactly equal.
- auto mat3i_eq(matrix3i a, matrix3i b) -> bool
- Returns true if two matrices are exactly equal.
- auto mat4i_eq(matrix4i a, matrix4i b) -> bool
- Returns true if two matrices are exactly equal.
Scalar-query pointer adapters
Header-only _ptr forms for functions that return a scalar or bool.
The by-value function is the body. Pointers must not be NULL. These are not SIMD kernels and are not exported from the library.
-
static auto mat2_determinant_ptr(const matrix2* m) -> vm_
float_ t - Pointer adapter for mat2_
determinant(). -
static auto mat3_determinant_ptr(const matrix3* m) -> vm_
float_ t - Pointer adapter for mat3_
determinant(). -
static auto mat4_determinant_ptr(const matrix4* m) -> vm_
float_ t - Pointer adapter for mat4_
determinant(). -
static auto mat2i_determinant_ptr(const matrix2i* m) -> vm_
int_ t - Pointer adapter for mat2i_
determinant(). -
static auto mat3i_determinant_ptr(const matrix3i* m) -> vm_
int_ t - Pointer adapter for mat3i_
determinant(). -
static auto mat4i_determinant_ptr(const matrix4i* m) -> vm_
int_ t - Pointer adapter for mat4i_
determinant(). - static auto mat2_eq_ptr(const matrix2* a, const matrix2* b) -> bool
- Pointer adapter for mat2_
eq(). - static auto mat3_eq_ptr(const matrix3* a, const matrix3* b) -> bool
- Pointer adapter for mat3_
eq(). - static auto mat4_eq_ptr(const matrix4* a, const matrix4* b) -> bool
- Pointer adapter for mat4_
eq(). - static auto mat2i_eq_ptr(const matrix2i* a, const matrix2i* b) -> bool
- Pointer adapter for mat2i_
eq(). - static auto mat3i_eq_ptr(const matrix3i* a, const matrix3i* b) -> bool
- Pointer adapter for mat3i_
eq(). - static auto mat4i_eq_ptr(const matrix4i* a, const matrix4i* b) -> bool
- Pointer adapter for mat4i_
eq().
Function documentation
matrix2 mat2_transpose(matrix2 m)
Computes the transpose of a 2x2 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The transposed matrix2. |
matrix2 mat2_inverse(matrix2 m)
Computes the inverse of a 2x2 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The inverse matrix2. |
matrix2 mat2_rotation_z(vm_ float_ t radians)
Constructs a 2x2 rotation matrix around the Z axis.
| Parameters | |
|---|---|
| radians | Rotation angle in radians. |
| Returns | The rotation matrix2. |
matrix2 mat2_rotation_z_deg(vm_ float_ t degrees)
Constructs a 2x2 rotation matrix from an angle in degrees around the Z axis.
| Parameters | |
|---|---|
| degrees | The rotation angle in degrees. |
| Returns | The rotation matrix2. |
matrix2 mat2_scale(vector2 s)
Builds a 2x2 scaling matrix from a vector2.
| Parameters | |
|---|---|
| s | Scale vector. |
| Returns | The resulting matrix2. |
matrix2 mat2_from_mat3(matrix3 m)
Copies the upper-left 2x2 of a matrix3.
| Parameters | |
|---|---|
| m | Input matrix. |
| Returns | The resulting matrix2. |
vm_ float_ t mat2_determinant(matrix2 m)
Calculates the determinant of the given 2x2 matrix.
| Parameters | |
|---|---|
| m | The matrix. |
| Returns | The determinant value (m.v[0]*m.v[3] - m.v[1]*m.v[2]). |
matrix3 mat3_transpose(matrix3 m)
Computes the transpose of a 3x3 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The transposed matrix. |
matrix3 mat3_inverse(matrix3 m)
Computes the inverse of a 3x3 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The inverse matrix. |
On a singular matrix the result is identity.
bool mat3_inverse_ok(matrix3* res, const matrix3* m)
Inverse of a 3×3 with an ok flag.
| Parameters | |
|---|---|
| res | Output inverse. |
| m | Input matrix. |
| Returns | true if invertible. |
Returns false and leaves *res unchanged if the matrix is singular (scale-aware cutoff). Otherwise writes the inverse and returns true.
bool mat3_polar(matrix3* R, matrix3* U, const matrix3* F)
Polar decomposition F = R U.
| Parameters | |
|---|---|
| R | Output rotation (proper). |
| U | Output stretch (symmetric positive definite). |
| F | Input deformation gradient. |
| Returns | true on success. |
U is symmetric positive definite, R is proper (det R = 1). Newton iteration on C = Fᵀ F, capped. Returns false on a singular matrix, a non-positive stretch, a reflection, or non-convergence.
matrix3 mat3_rotation_x(vm_ float_ t radians)
Constructs a 3x3 rotation matrix around the X axis.
| Parameters | |
|---|---|
| radians | Rotation angle in radians. |
| Returns | The rotation matrix3. |
matrix3 mat3_rotation_y(vm_ float_ t radians)
Constructs a 3x3 rotation matrix around the Y axis.
| Parameters | |
|---|---|
| radians | The rotation angle in radians. |
| Returns | The rotation matrix3. |
matrix3 mat3_rotation_z(vm_ float_ t radians)
Constructs a 3x3 rotation matrix around the Z axis.
| Parameters | |
|---|---|
| radians | Rotation angle in radians. |
| Returns | The rotation matrix3. |
matrix3 mat3_rotation_x_deg(vm_ float_ t degrees)
Constructs a 3x3 rotation matrix around the X axis.
| Parameters | |
|---|---|
| degrees | The rotation angle in degrees. |
| Returns | The rotation matrix3. |
The angle is provided in degrees and converted to radians internally.
matrix3 mat3_rotation_y_deg(vm_ float_ t degrees)
3x3 rotation about Y from an angle in degrees.
| Parameters | |
|---|---|
| degrees | Rotation angle in degrees. |
| Returns | Rotation matrix3. |
matrix3 mat3_rotation_z_deg(vm_ float_ t degrees)
Constructs a 3x3 rotation matrix around the Z axis.
| Parameters | |
|---|---|
| degrees | The rotation angle in degrees. |
| Returns | The resulting rotation matrix3. |
The angle is given in degrees and internally converted to radians.
matrix3 mat3_translate(vector2 t)
Builds a 3x3 2D translation matrix.
| Parameters | |
|---|---|
| t | Translation vector. |
| Returns | The resulting matrix3. |
matrix3 mat3_scale(vector2 s)
Builds a 3x3 2D scaling matrix.
| Parameters | |
|---|---|
| s | Scale vector. |
| Returns | The resulting matrix3. |
matrix3 mat3_normal(matrix3 m)
Inverse-transpose of a 3x3 (normal matrix).
| Parameters | |
|---|---|
| m | Linear part of a model transform. |
| Returns | The normal matrix3. |
matrix3 mat3_from_mat4(matrix4 m)
Copies the upper-left 3x3 of a matrix4.
| Parameters | |
|---|---|
| m | Input matrix. |
| Returns | The resulting matrix3. |
vector3 mat3_sym_eigen(matrix3 m, matrix3* axes)
Analytical eigenvalues of a symmetric 3×3, sorted ascending.
| Parameters | |
|---|---|
| m | Input matrix (symmetrized internally). |
| axes | Optional; receives eigenvector columns. May be NULL. |
| Returns | Eigenvalues as a vector3, sorted ascending. |
m is symmetrized as (A+Aᵀ)/2. Eigenvalues are sorted ascending. Eigenvectors are the columns of axes when non-NULL (axes * diag(moments) * axesᵀ ~= m). Analytical closed form; not routed through heap SVD or Jacobi.
vm_ float_ t mat3_determinant(matrix3 m)
Computes the determinant of a 3x3 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The determinant value. |
matrix4 mat4_transpose(matrix4 m)
Computes the transpose of a 4x4 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The transposed matrix4. |
matrix4 mat4_inverse(matrix4 m)
Computes the inverse of a 4x4 matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The inverse matrix4. |
matrix4 mat4_inverse_affine(matrix4 m)
Inverse of an affine matrix [R t; 0 1].
| Parameters | |
|---|---|
| m | Affine 4×4 matrix. |
| Returns | Inverse matrix. |
Inverts an [A t; 0 1] affine transform without the full 4x4 adjugate.
matrix4 mat4_translate(vector3 v)
Constructs a translation matrix from the given vector.
| Parameters | |
|---|---|
| v | The translation vector (x, y, z). |
| Returns | The translation matrix4. |
matrix4 mat4_scale(vector3 v)
Constructs a scaling matrix from the given scale vector.
| Parameters | |
|---|---|
| v | The scale vector (x, y, z factors). |
| Returns | The resulting scaling matrix4. |
matrix4 mat4_normal(matrix4 m)
Inverse-transpose of the upper 3x3, embedded in a matrix4.
| Parameters | |
|---|---|
| m | Model matrix. |
| Returns | Normal matrix as a matrix4. |
matrix4 mat4_rotation(vector3 axis,
vm_ float_ t radians)
Constructs a 4x4 rotation matrix.
| Parameters | |
|---|---|
| axis | The rotation axis. |
| radians | The rotation angle in radians. |
| Returns | The rotation matrix4. |
matrix4 mat4_rotation_x(vm_ float_ t radians)
Constructs a 4x4 rotation matrix around the X axis.
| Parameters | |
|---|---|
| radians | Rotation angle in radians. |
| Returns | The rotation matrix4. |
matrix4 mat4_rotation_y(vm_ float_ t radians)
Constructs a 4x4 rotation matrix around the Y axis.
| Parameters | |
|---|---|
| radians | The rotation angle in radians. |
| Returns | The rotation matrix4. |
matrix4 mat4_rotation_z(vm_ float_ t radians)
Constructs a 4x4 rotation matrix around the Z axis.
| Parameters | |
|---|---|
| radians | Rotation angle in radians. |
| Returns | The rotation matrix4. |
matrix4 mat4_rotation_deg(vector3 axis,
vm_ float_ t degrees)
Constructs a 4x4 rotation matrix from an axis and angle in degrees.
| Parameters | |
|---|---|
| axis | The rotation axis. |
| degrees | The rotation angle in degrees. |
| Returns | The rotation matrix4. |
matrix4 mat4_rotation_x_deg(vm_ float_ t degrees)
Constructs a 4x4 rotation matrix around the X axis.
| Parameters | |
|---|---|
| degrees | The rotation angle in degrees. |
| Returns | The rotation matrix4. |
The angle is specified in degrees and internally converted to radians.
matrix4 mat4_rotation_y_deg(vm_ float_ t degrees)
Constructs a 4x4 rotation matrix around the Y axis.
| Parameters | |
|---|---|
| degrees | Rotation angle in degrees. |
| Returns | The rotation matrix4. |
matrix4 mat4_rotation_z_deg(vm_ float_ t degrees)
Constructs a 4x4 rotation matrix around the Z axis from an angle in degrees.
| Parameters | |
|---|---|
| degrees | The rotation angle in degrees. |
| Returns | The rotation matrix4. |
vm_ float_ t mat4_determinant(matrix4 m)
Calculates the determinant of the given 4x4 matrix.
| Parameters | |
|---|---|
| m | The matrix. |
| Returns | The determinant value as a vm_ |
Uses cofactor expansion for computation.
vector3 mat4_extract_translation(matrix4 m)
Extracts the translation vector from a matrix4.
| Parameters | |
|---|---|
| m | Input matrix. |
| Returns | The resulting vector3. |
vector3 mat4_extract_scale(matrix4 m)
Extracts the scale vector from a matrix4.
| Parameters | |
|---|---|
| m | Input matrix. |
| Returns | The resulting vector3. |
vector3 mat4_mul_vec3(matrix4 m,
vector3 v,
vm_ float_ t w)
Transforms a vector3 by a 4x4 matrix using homogeneous w.
| Parameters | |
|---|---|
| m | Input matrix. |
| v | Input vector. |
| w | Homogeneous w component. |
| Returns | The resulting vector3. |
quaternion mat4_extract_rotation(matrix4 m)
Extracts the rotation quaternion from a matrix4.
| Parameters | |
|---|---|
| m | Input matrix. |
| Returns | The resulting quaternion. |
void mat2_identity_ptr(matrix2* res)
Initializes the 2x2 matrix to identity (diagonal 1.0, others 0.0).
| Parameters | |
|---|---|
| res | Pointer to the output matrix2. |
void mat2_mul_ptr(matrix2* res, const matrix2* a, const matrix2* b)
Multiplies two 2x2 matrices (a * b) in column-major / column-vector convention.
| Parameters | |
|---|---|
| res | Pointer to the output matrix2. |
| a | Pointer to the first matrix. |
| b | Pointer to the second matrix. |
Column-major product AB so (AB)v == A(Bv) (column vector on the right).
void mat2_transpose_ptr(matrix2* res, const matrix2* m)
Computes the transpose of the input 2x2 matrix and stores in res.
| Parameters | |
|---|---|
| res | Pointer to the output matrix2. |
| m | Pointer to the input matrix. |
void mat2_inverse_ptr(matrix2* res, const matrix2* m)
Computes the inverse of the input 2x2 matrix using determinant and stores in res.
| Parameters | |
|---|---|
| res | Pointer to the output matrix2. |
| m | Pointer to the input matrix. |
If the determinant is zero, sets res to identity matrix.
void mat2_rotation_z_ptr(matrix2* res,
vm_ float_ t radians)
Sets the 2x2 matrix to a Z-axis (counter-clockwise) rotation.
| Parameters | |
|---|---|
| res | Pointer to the output matrix2. |
| radians | Rotation angle in radians. |
void mat2_rotation_z_deg_ptr(matrix2* res,
vm_ float_ t degrees)
Initializes the 2x2 matrix to a rotation around Z axis (counter-clockwise).
| Parameters | |
|---|---|
| res | Pointer to the output matrix2. |
| degrees | Rotation angle in degrees. |
void mat2_scale_ptr(matrix2* res, const vector2* s)
Builds a 2x2 scaling matrix from a vector2.
| Parameters | |
|---|---|
| res | Output value. |
| s | Scale vector. |
void mat2_from_mat3_ptr(matrix2* res, const matrix3* m)
Copies the upper-left 2x2 of a matrix3.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
void mat2_mul_vec2_ptr(vector2* res, const matrix2* m, const vector2* v)
Multiplies a 2x2 matrix by a vector2.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
| v | Input vector. |
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.
Column-major product AB so (AB)v == A(Bv) (column vector on the right).
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_x_ptr(matrix3* res,
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_y_ptr(matrix3* res,
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_z_ptr(matrix3* res,
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_x_deg_ptr(matrix3* res,
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_deg_ptr(matrix3* res,
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_rotation_z_deg_ptr(matrix3* res,
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_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. |
void mat3_sym_eigen_ptr(vector3* eigenvalues, matrix3* axes, const matrix3* m)
Analytical eigensolve of a symmetric 3x3 matrix.
| Parameters | |
|---|---|
| eigenvalues | Output eigenvalues (sorted ascending). |
| axes | Output eigenvector columns, or NULL. |
| m | Input matrix (copied and symmetrized). |
m is first replaced by (m + m^T) / 2. Eigenvalues are sorted ascending. Eigenvector i is column i of axes when axes is non-NULL. Analytical closed form.
void mat4_identity_ptr(matrix4* res)
Sets the matrix to the identity matrix.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 to set to identity. |
The identity matrix is a 4x4 matrix with 1s on the main diagonal and 0s elsewhere.
void mat4_mul_ptr(matrix4* res, const matrix4* a, const matrix4* b)
Multiplies two 4x4 matrices (dispatched).
| Parameters | |
|---|---|
| res | Result matrix. |
| a | Left matrix. |
| b | Right matrix. |
Column-major product AB so (AB)v == A(Bv) (column vector on the right).
void mat4_transpose_ptr(matrix4* res, const matrix4* m)
Transposes a 4x4 matrix (dispatched).
| Parameters | |
|---|---|
| res | Result matrix. |
| m | Input matrix. |
void mat4_inverse_ptr(matrix4* res, const matrix4* m)
Computes the inverse of a 4x4 matrix.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 where the inverse will be stored. |
| m | Pointer to the matrix4 to invert. |
This function calculates the inverse of the given 4x4 matrix using the adjugate matrix and determinant. If the matrix is singular (determinant is zero), the result is set to the identity matrix.
void mat4_inverse_affine_ptr(matrix4* res, const matrix4* m)
Inverse of an affine matrix [R t; 0 1].
| Parameters | |
|---|---|
| res | Output inverse matrix. |
| m | Affine 4×4 matrix. |
Inverts the upper-left 3×3 and corrects the translation. Last row is fixed as [0 0 0 1]. For a full 4×4 inverse, use mat4_. Singular 3×3 yields identity.
void mat4_translate_ptr(matrix4* res, const vector3* v)
Sets the matrix to a translation matrix.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 to set. |
| v | Pointer to the vector3 containing the translation values. |
This function initializes a 4x4 matrix to represent a translation transformation based on the provided vector, with the translation components placed in the last column and the rest forming an identity matrix.
void mat4_scale_ptr(matrix4* res, const vector3* v)
Sets the matrix to a scaling matrix using the provided scale vector.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 to set as a scaling matrix. |
| v | Pointer to the vector3 containing the scale factors (x, y, z). |
This function constructs a 4x4 scaling matrix where the diagonal elements correspond to the x, y, and z scale factors from the input vector. The bottom-right element is set to 1.0f for homogeneous coordinates. All other elements are implicitly zero (not set, assuming the matrix is initialized).
void mat4_normal_ptr(matrix4* res, const matrix4* m)
Inverse-transpose of the upper-left 3x3, embedded in a matrix4.
| Parameters | |
|---|---|
| res | Normal matrix as a matrix4. |
| m | Model matrix. |
Used to transform surface normals under a (possibly non-uniformly scaled) model matrix. Last row/column stay identity.
void mat4_rotation_ptr(matrix4* res,
const vector3* axis,
vm_ float_ t radians)
Sets the matrix to a rotation matrix around the given axis.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 that will receive the rotation matrix. |
| axis | Pointer to the vector3 representing the rotation axis. |
| radians | The rotation angle in radians. |
Constructs a 4x4 rotation matrix that rotates by the specified angle (in radians) around the provided axis. The axis vector is normalized internally.
void mat4_rotation_x_ptr(matrix4* res,
vm_ float_ t radians)
Builds a 4x4 rotation matrix around the X axis (radians).
| Parameters | |
|---|---|
| res | Result matrix. |
| radians | Rotation angle in radians. |
void mat4_rotation_y_ptr(matrix4* res,
vm_ float_ t radians)
Sets the matrix to a rotation matrix around the Y axis.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 to store the result. |
| radians | Rotation angle in radians. |
void mat4_rotation_z_ptr(matrix4* res,
vm_ float_ t radians)
Sets the matrix to a rotation around the Z axis.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 to store the result. |
| radians | Rotation angle in radians. |
void mat4_rotation_deg_ptr(matrix4* res,
const vector3* axis,
vm_ float_ t degrees)
Sets the matrix to a rotation matrix using an axis and angle in degrees.
| Parameters | |
|---|---|
| res | Pointer to the matrix4 that will receive the rotation matrix. |
| axis | Pointer to the vector3 defining the rotation axis. |
| degrees | The rotation angle in degrees. |
void mat4_rotation_x_deg_ptr(matrix4* res,
vm_ float_ t degrees)
Builds a 4x4 rotation matrix around the X axis (degrees).
| Parameters | |
|---|---|
| res | Output value. |
| degrees | Rotation angle in degrees. |
void mat4_rotation_y_deg_ptr(matrix4* res,
vm_ float_ t degrees)
Builds a 4x4 rotation matrix around the Y axis (degrees).
| Parameters | |
|---|---|
| res | Output value. |
| degrees | Rotation angle in degrees. |
void mat4_rotation_z_deg_ptr(matrix4* res,
vm_ float_ t degrees)
Builds a 4x4 rotation matrix around the Z axis (degrees).
| Parameters | |
|---|---|
| res | Output value. |
| degrees | Rotation angle in degrees. |
void mat4_trs_ptr(matrix4* res, const vector3* translation, const quaternion* rotation, const vector3* scale)
Builds a 4x4 TRS matrix from translation, rotation, and scale.
| Parameters | |
|---|---|
| res | Output value. |
| translation | Translation vector. |
| rotation | Rotation quaternion. |
| scale | Scale vector. |
void mat4_from_mat3_ptr(matrix4* res, const matrix3* m)
Embeds a matrix3 into the upper-left of a matrix4.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
void mat4_extract_translation_ptr(vector3* res, const matrix4* m)
Extracts the translation vector from a matrix4.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
void mat4_extract_scale_ptr(vector3* res, const matrix4* m)
Extracts the scale vector from a matrix4.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
void mat4_extract_rotation_ptr(quaternion* res, const matrix4* m)
Extracts the rotation quaternion from a matrix4.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
void mat4_mul_vec4_ptr(vector4* res, const matrix4* m, const vector4* v)
Transforms a vector4 by a 4x4 matrix (dispatched).
| Parameters | |
|---|---|
| res | Result vector. |
| m | Input matrix. |
| v | Input vector. |
void mat4_mul_vec3_ptr(vector3* res,
const matrix4* m,
const vector3* v,
vm_ float_ t w)
Transforms a vector3 by a 4x4 matrix using homogeneous w (dispatched).
| Parameters | |
|---|---|
| res | Result vector. |
| m | Input matrix. |
| v | Input vector. |
| w | Homogeneous w component. |
matrix2i mat2i_identity(void)
Constructs the 2x2 integer identity matrix.
| Returns | The identity matrix2i. |
|---|
matrix2i mat2i_transpose(matrix2i m)
Computes the transpose of a 2x2 integer matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The transposed matrix2i. |
matrix2i mat2i_inverse(matrix2i m)
Computes the inverse of a 2x2 integer matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The inverse matrix2i. |
Truncated integer inverse (not a modular inverse).
vm_ int_ t mat2i_determinant(matrix2i m)
Calculates the determinant of the given 2x2 integer matrix.
| Parameters | |
|---|---|
| m | The matrix. |
| Returns | The determinant value (m.v[0]*m.v[3] - m.v[1]*m.v[2]). |
matrix3i mat3i_transpose(matrix3i m)
Computes the transpose of a 3x3 integer matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The transposed matrix. |
matrix3i mat3i_inverse(matrix3i m)
Computes the inverse of a 3x3 integer matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The inverse matrix. |
Truncated integer inverse (not a modular inverse).
vm_ int_ t mat3i_determinant(matrix3i m)
Computes the determinant of a 3x3 integer matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The determinant value. |
matrix4i mat4i_transpose(matrix4i m)
Computes the transpose of a 4x4 integer matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The transposed matrix. |
matrix4i mat4i_inverse(matrix4i m)
Computes the inverse of a 4x4 integer matrix.
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The inverse matrix. |
Truncated integer inverse (not a modular inverse).
vm_ int_ t mat4i_determinant(matrix4i m)
Computes the determinant of a 4x4 integer matrix (Laplace expansion along first row).
| Parameters | |
|---|---|
| m | The input matrix. |
| Returns | The determinant value. |
void mat2i_identity_ptr(matrix2i* res)
Initializes the integer 2x2 matrix to identity (diagonal 1, others 0).
| Parameters | |
|---|---|
| res | Pointer to the output matrix2i. |
void mat2i_mul_ptr(matrix2i* res, const matrix2i* a, const matrix2i* b)
Multiplies two integer 2x2 matrices (a * b) using explicit loops and stores the result in res.
| Parameters | |
|---|---|
| res | Pointer to the output matrix2i. |
| a | Pointer to the first matrix. |
| b | Pointer to the second matrix. |
Column-major product AB so (AB)v == A(Bv) (column vector on the right).
void mat2i_transpose_ptr(matrix2i* res, const matrix2i* m)
Computes the transpose of the input integer 2x2 matrix and stores in res.
| Parameters | |
|---|---|
| res | Pointer to the output matrix2i. |
| m | Pointer to the input matrix. |
void mat2i_inverse_ptr(matrix2i* res, const matrix2i* m)
Computes the inverse of the input integer 2x2 matrix and stores in res.
| Parameters | |
|---|---|
| res | Pointer to the output matrix2i. |
| m | Pointer to the input matrix. |
Uses double precision for inversion, truncates to int; sets to identity if det=0.
Truncated integer inverse (not a modular inverse).
void mat2i_mul_vec2i_ptr(vector2i* res, const matrix2i* m, const vector2i* v)
Multiplies a 2x2 integer matrix by a vector2i.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
| v | Input vector. |
void mat3i_identity_ptr(matrix3i* res)
Fills the given 3x3 integer matrix with the identity matrix.
| Parameters | |
|---|---|
| res | Pointer to the result matrix. |
void mat3i_mul_ptr(matrix3i* res, const matrix3i* a, const matrix3i* b)
Multiplies two 3x3 integer matrices (standard matrix multiplication).
| Parameters | |
|---|---|
| res | Pointer to the result matrix. |
| a | Pointer to the first input matrix. |
| b | Pointer to the second input matrix. |
Column-major product AB so (AB)v == A(Bv) (column vector on the right).
void mat3i_transpose_ptr(matrix3i* res, const matrix3i* m)
Computes the transpose of a 3x3 integer matrix.
| Parameters | |
|---|---|
| res | Pointer to the result matrix. |
| m | Pointer to the input matrix. |
void mat3i_inverse_ptr(matrix3i* res, const matrix3i* m)
Computes the inverse of a 3x3 integer matrix using adjugate over determinant.
| Parameters | |
|---|---|
| res | Pointer to the result matrix. |
| m | Pointer to the input matrix. |
If the determinant is zero (singular), sets the result to the identity matrix.
Truncated integer inverse (not a modular inverse).
void mat3i_mul_vec3i_ptr(vector3i* res, const matrix3i* m, const vector3i* v)
Multiplies a 3x3 integer matrix by a vector3i.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
| v | Input vector. |
void mat3i_mul_vec2i_ptr(vector2i* res, const matrix3i* m, const vector2i* v)
Applies a 3x3 integer affine transform to a vector2i.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
| v | Input vector. |
void mat4i_identity_ptr(matrix4i* res)
Sets the given 4x4 integer matrix to the identity matrix.
| Parameters | |
|---|---|
| res | Pointer to the matrix structure to set to identity. |
void mat4i_mul_ptr(matrix4i* res, const matrix4i* a, const matrix4i* b)
Performs matrix multiplication of two 4x4 matrices and stores the result.
| Parameters | |
|---|---|
| res | Pointer to the matrix structure to store the result of the multiplication. |
| a | Pointer to the first matrix operand. |
| b | Pointer to the second matrix operand. |
Column-major product AB so (AB)v == A(Bv) (column vector on the right).
void mat4i_transpose_ptr(matrix4i* res, const matrix4i* m)
Transposes the given 4x4 integer matrix and stores the result in the provided matrix structure.
| Parameters | |
|---|---|
| res | Pointer to the matrix structure to store the transposed matrix. |
| m | Pointer to the input matrix to be transposed. |
void mat4i_inverse_ptr(matrix4i* res, const matrix4i* m)
Computes the inverse of the given 4x4 integer matrix and stores the result in the specified matrix.
| Parameters | |
|---|---|
| res | Pointer to the matrix structure to store the inverse matrix. |
| m | Pointer to the constant matrix to be inverted. |
If the matrix is singular (determinant is zero), the result is set to the identity matrix.
Truncated integer inverse (not a modular inverse).
void mat4i_mul_vec4i_ptr(vector4i* res, const matrix4i* m, const vector4i* v)
Multiplies a 4x4 integer matrix by a vector4i.
| Parameters | |
|---|---|
| res | Output value. |
| m | Input matrix. |
| v | Input vector. |
bool mat2_eq(matrix2 a, matrix2 b)
Returns true if two matrices are equal within VECMAT_.
| Parameters | |
|---|---|
| a | First matrix. |
| b | Second matrix. |
| Returns | True if a and b are approximately equal. |
bool mat3_eq(matrix3 a, matrix3 b)
Returns true if two matrices are equal within VECMAT_.
| Parameters | |
|---|---|
| a | First matrix. |
| b | Second matrix. |
| Returns | True if a and b are approximately equal. |
bool mat4_eq(matrix4 a, matrix4 b)
Returns true if two matrices are equal within VECMAT_.
| Parameters | |
|---|---|
| a | First matrix. |
| b | Second matrix. |
| Returns | True if a and b are approximately equal. |
static vm_ float_ t mat2_determinant_ptr(const matrix2* m)
Pointer adapter for mat2_
| Parameters | |
|---|---|
| m | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static vm_ float_ t mat3_determinant_ptr(const matrix3* m)
Pointer adapter for mat3_
| Parameters | |
|---|---|
| m | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static vm_ float_ t mat4_determinant_ptr(const matrix4* m)
Pointer adapter for mat4_
| Parameters | |
|---|---|
| m | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static vm_ int_ t mat2i_determinant_ptr(const matrix2i* m)
Pointer adapter for mat2i_
| Parameters | |
|---|---|
| m | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static vm_ int_ t mat3i_determinant_ptr(const matrix3i* m)
Pointer adapter for mat3i_
| Parameters | |
|---|---|
| m | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static vm_ int_ t mat4i_determinant_ptr(const matrix4i* m)
Pointer adapter for mat4i_
| Parameters | |
|---|---|
| m | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static bool mat2_eq_ptr(const matrix2* a, const matrix2* b)
Pointer adapter for mat2_
| Parameters | |
|---|---|
| a | Must not be NULL. |
| b | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static bool mat3_eq_ptr(const matrix3* a, const matrix3* b)
Pointer adapter for mat3_
| Parameters | |
|---|---|
| a | Must not be NULL. |
| b | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static bool mat4_eq_ptr(const matrix4* a, const matrix4* b)
Pointer adapter for mat4_
| Parameters | |
|---|---|
| a | Must not be NULL. |
| b | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static bool mat2i_eq_ptr(const matrix2i* a, const matrix2i* b)
Pointer adapter for mat2i_
| Parameters | |
|---|---|
| a | Must not be NULL. |
| b | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static bool mat3i_eq_ptr(const matrix3i* a, const matrix3i* b)
Pointer adapter for mat3i_
| Parameters | |
|---|---|
| a | Must not be NULL. |
| b | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.
static bool mat4i_eq_ptr(const matrix4i* a, const matrix4i* b)
Pointer adapter for mat4i_
| Parameters | |
|---|---|
| a | Must not be NULL. |
| b | Must not be NULL. |
| Returns | Same value as the by-value function. |
Same result as the by-value function.