src/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, 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, vm_float_t degrees)
Initializes the 3x3 matrix to a rotation around the Z axis.
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_x_deg_ptr(matrix3* res, vm_float_t degrees)
Initializes 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_y_deg_ptr(matrix3* res, 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.

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.

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_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_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_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_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_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_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_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.