src/matrix2.c file

Functions

auto mat2_identity(void) -> matrix2
Constructs the 2x2 identity matrix.
auto mat2_mul(const matrix2 a, const matrix2 b) -> matrix2
Multiplies two 2x2 matrices (a * b).
auto mat2_transpose(const matrix2 m) -> matrix2
Computes the transpose of a 2x2 matrix.
auto mat2_inverse(const matrix2 m) -> matrix2
Computes the inverse of a 2x2 matrix.
auto mat2_rotation_z(const vm_float_t radians) -> matrix2
Constructs a 2x2 rotation matrix around the Z axis.
auto mat2_rotation_z_deg(const vm_float_t degrees) -> matrix2
Constructs a 2x2 rotation matrix from an angle in degrees around the Z axis.
auto mat2_determinant(const matrix2 m) -> vm_float_t
Calculates the determinant of the given 2x2 matrix.
auto mat2_mul_vec2(const matrix2 m, const vector2 v) -> vector2
Multiplies a 2x2 matrix by a vector2.
auto mat2_scale(const vector2 s) -> matrix2
Builds a 2x2 scaling matrix from a vector2.
auto mat2_from_mat3(const matrix3 m) -> matrix2
Copies the upper-left 2x2 of a matrix3.

Function documentation

matrix2 mat2_identity(void)

Constructs the 2x2 identity matrix.

Returns The identity matrix2.

matrix2 mat2_mul(const matrix2 a, const matrix2 b)

Multiplies two 2x2 matrices (a * b).

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

matrix2 mat2_transpose(const matrix2 m)

Computes the transpose of a 2x2 matrix.

Parameters
m The input matrix.
Returns The transposed matrix2.

matrix2 mat2_inverse(const matrix2 m)

Computes the inverse of a 2x2 matrix.

Parameters
m The input matrix.
Returns The inverse matrix2.

matrix2 mat2_rotation_z(const 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(const 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.

vm_float_t mat2_determinant(const 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]).

vector2 mat2_mul_vec2(const matrix2 m, const vector2 v)

Multiplies a 2x2 matrix by a vector2.

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

matrix2 mat2_scale(const vector2 s)

Builds a 2x2 scaling matrix from a vector2.

Parameters
s Scale vector.
Returns The resulting matrix2.

matrix2 mat2_from_mat3(const matrix3 m)

Copies the upper-left 2x2 of a matrix3.

Parameters
m Input matrix.
Returns The resulting matrix2.