src/matrix3.c file

Functions

auto mat3_identity(void) -> matrix3
Constructs the 3x3 identity matrix.
auto mat3_mul(const matrix3 a, const matrix3 b) -> matrix3
Multiplies two 3x3 matrices.
auto mat3_transpose(const matrix3 m) -> matrix3
Computes the transpose of a 3x3 matrix.
auto mat3_inverse(const matrix3 m) -> matrix3
Computes the inverse of a 3x3 matrix.
auto mat3_rotation_z(const vm_float_t radians) -> matrix3
Constructs a 3x3 rotation matrix around the Z axis.
auto mat3_rotation_z_deg(const vm_float_t degrees) -> matrix3
Constructs a 3x3 rotation matrix around the Z axis.
auto mat3_determinant(const matrix3 m) -> vm_float_t
Computes the determinant of a 3x3 matrix.
auto mat3_mul_vec3(const matrix3 m, const vector3 v) -> vector3
Multiplies a 3x3 matrix by a vector3.
auto mat3_mul_vec2(const matrix3 m, const vector2 v) -> vector2
Applies a 3x3 affine transform to a vector2.
auto mat3_rotation_x(const vm_float_t radians) -> matrix3
Constructs a 3x3 rotation matrix around the X axis.
auto mat3_rotation_x_deg(const vm_float_t degrees) -> matrix3
Constructs a 3x3 rotation matrix around the X axis.
auto mat3_rotation_y(const vm_float_t radians) -> matrix3
Constructs a 3x3 rotation matrix around the Y axis.
auto mat3_rotation_y_deg(const vm_float_t degrees) -> matrix3
3x3 rotation about Y from an angle in degrees.
auto mat3_translate(const vector2 t) -> matrix3
Builds a 3x3 2D translation matrix.
auto mat3_scale(const vector2 s) -> matrix3
Builds a 3x3 2D scaling matrix.
auto mat3_from_mat4(const matrix4 m) -> matrix3
Copies the upper-left 3x3 of a matrix4.
auto mat3_normal(const matrix3 m) -> matrix3
Inverse-transpose of a 3x3 (normal matrix).
auto mat3_sym_eigen(const matrix3 m, matrix3* axes) -> vector3
Symmetric 3x3 eigensolve (Jacobi).

Function documentation

matrix3 mat3_identity(void)

Constructs the 3x3 identity matrix.

Returns The identity matrix3.

matrix3 mat3_mul(const matrix3 a, const matrix3 b)

Multiplies two 3x3 matrices.

Parameters
a The first matrix.
b The second matrix.
Returns The product matrix.

matrix3 mat3_transpose(const matrix3 m)

Computes the transpose of a 3x3 matrix.

Parameters
m The input matrix.
Returns The transposed matrix.

matrix3 mat3_inverse(const matrix3 m)

Computes the inverse of a 3x3 matrix.

Parameters
m The input matrix.
Returns The inverse matrix.

matrix3 mat3_rotation_z(const 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_z_deg(const 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.

vm_float_t mat3_determinant(const matrix3 m)

Computes the determinant of a 3x3 matrix.

Parameters
m The input matrix.
Returns The determinant value.

vector3 mat3_mul_vec3(const matrix3 m, const vector3 v)

Multiplies a 3x3 matrix by a vector3.

Parameters
m Input matrix.
v Input vector.
Returns The resulting vector3.

vector2 mat3_mul_vec2(const matrix3 m, const vector2 v)

Applies a 3x3 affine transform to a vector2.

Parameters
m Input matrix.
v Input vector.
Returns The resulting vector2.

matrix3 mat3_rotation_x(const 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_x_deg(const 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(const 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_y_deg(const vm_float_t degrees)

3x3 rotation about Y from an angle in degrees.

Parameters
degrees Rotation angle in degrees.
Returns Rotation matrix3.

matrix3 mat3_translate(const vector2 t)

Builds a 3x3 2D translation matrix.

Parameters
t Translation vector.
Returns The resulting matrix3.

matrix3 mat3_scale(const vector2 s)

Builds a 3x3 2D scaling matrix.

Parameters
s Scale vector.
Returns The resulting matrix3.

matrix3 mat3_from_mat4(const matrix4 m)

Copies the upper-left 3x3 of a matrix4.

Parameters
m Input matrix.
Returns The resulting matrix3.

matrix3 mat3_normal(const matrix3 m)

Inverse-transpose of a 3x3 (normal matrix).

Parameters
m Linear part of a model transform.
Returns The normal matrix3.

vector3 mat3_sym_eigen(const matrix3 m, matrix3* axes)

Symmetric 3x3 eigensolve (Jacobi).

Parameters
m Input matrix (symmetrized internally).
axes Optional; receives eigenvector columns. May be NULL.
Returns Eigenvalues as a vector3.

m is symmetrized as (A+A^T)/2.

Eigenvalues are unsorted principal moments. Eigenvectors are the columns of the returned rotation (axes * diag(moments) * axes^T ~= m).