Vecmat 0.2.3
C math and linear algebra library for 2D/3D graphics, physics, and science.
Loading...
Searching...
No Matches
matrix2.c File Reference
#include <vecmat.h>

Go to the source code of this file.

Functions

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

Function Documentation

◆ mat2_determinant()

vm_float_t mat2_determinant ( const matrix2 m)

Calculates the determinant of the given 2x2 matrix.

Parameters
mThe matrix.
Returns
The determinant value (m.v[0]*m.v[3] - m.v[1]*m.v[2]).

Definition at line 88 of file matrix2.c.

References matrix2::v.

Referenced by mat2_inverse_ptr().

◆ mat2_from_mat3()

matrix2 mat2_from_mat3 ( const matrix3 m)

Copies the upper-left 2x2 of a matrix3.

See mat2_from_mat3_ptr instead.

Parameters
mInput matrix.
Returns
The resulting matrix2.

Definition at line 132 of file matrix2.c.

References mat2_from_mat3_ptr().

◆ mat2_identity()

matrix2 mat2_identity ( void )

Constructs the 2x2 identity matrix.

See mat2_identity_ptr instead.

Returns
The identity matrix2.

Definition at line 14 of file matrix2.c.

References mat2_identity_ptr().

◆ mat2_inverse()

matrix2 mat2_inverse ( const matrix2 m)

Computes the inverse of a 2x2 matrix.

See mat2_inverse_ptr instead.

Parameters
mThe input matrix.
Returns
The inverse matrix2.

Definition at line 60 of file matrix2.c.

References mat2_inverse_ptr().

◆ mat2_mul()

matrix2 mat2_mul ( const matrix2 a,
const matrix2 b )

Multiplies two 2x2 matrices (a * b).

See mat2_mul_ptr instead.

Parameters
aThe first matrix.
bThe second matrix.
Returns
The resulting product matrix2.

Definition at line 30 of file matrix2.c.

References mat2_mul_ptr().

◆ mat2_mul_vec2()

vector2 mat2_mul_vec2 ( const matrix2 m,
const vector2 v )

Multiplies a 2x2 matrix by a vector2.

See mat2_mul_vec2_ptr instead.

Parameters
mInput matrix.
vInput vector.
Returns
The resulting vector2.

Definition at line 102 of file matrix2.c.

References mat2_mul_vec2_ptr().

◆ mat2_rotation_z()

matrix2 mat2_rotation_z ( const vm_float_t degrees)

Constructs a 2x2 Z-axis rotation matrix.

See mat2_rotation_z_ptr instead.

Parameters
degreesRotation angle in degrees.
Returns
The rotation matrix2.

Definition at line 75 of file matrix2.c.

References mat2_rotation_z_ptr().

◆ mat2_scale()

matrix2 mat2_scale ( const vector2 s)

Builds a 2x2 scaling matrix from a vector2.

See mat2_scale_ptr instead.

Parameters
sScale vector.
Returns
The resulting matrix2.

Definition at line 117 of file matrix2.c.

References mat2_scale_ptr().

◆ mat2_transpose()

matrix2 mat2_transpose ( const matrix2 m)

Computes the transpose of a 2x2 matrix.

See mat2_transpose_ptr instead.

Parameters
mThe input matrix.
Returns
The transposed matrix2.

Definition at line 45 of file matrix2.c.

References mat2_transpose_ptr().