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

Go to the source code of this file.

Functions

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.

Function Documentation

◆ mat2i_identity_ptr()

void mat2i_identity_ptr ( matrix2i * res)

Initializes the integer 2x2 matrix to identity (diagonal 1, others 0).

Parameters
resPointer to the output matrix2i.

Definition at line 12 of file matrix2i_ptr.c.

References matrix2i::v.

Referenced by mat2i_identity(), and mat2i_inverse_ptr().

◆ mat2i_inverse_ptr()

void mat2i_inverse_ptr ( matrix2i * res,
const matrix2i * m )

Computes the inverse of the input integer 2x2 matrix and stores in res.

Uses double precision for inversion, truncates to int; sets to identity if det=0.

Parameters
resPointer to the output matrix2i.
mPointer to the input matrix.

Definition at line 60 of file matrix2i_ptr.c.

References mat2i_determinant(), mat2i_identity_ptr(), and matrix2i::v.

Referenced by mat2i_inverse().

◆ mat2i_mul_ptr()

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
resPointer to the output matrix2i.
aPointer to the first matrix.
bPointer to the second matrix.

Definition at line 27 of file matrix2i_ptr.c.

References matrix2i::m11, matrix2i::m12, matrix2i::m21, and matrix2i::m22.

Referenced by mat2i_mul().

◆ mat2i_mul_vec2i_ptr()

void mat2i_mul_vec2i_ptr ( vector2i * res,
const matrix2i * m,
const vector2i * v )

Multiplies a 2x2 integer matrix by a vector2i.

Parameters
resOutput value.
mInput matrix.
vInput vector.

Definition at line 81 of file matrix2i_ptr.c.

References matrix2i::m11, matrix2i::m12, matrix2i::m21, matrix2i::m22, vector2i::x, and vector2i::y.

Referenced by mat2i_mul_vec2i().

◆ mat2i_transpose_ptr()

void mat2i_transpose_ptr ( matrix2i * res,
const matrix2i * m )

Computes the transpose of the input integer 2x2 matrix and stores in res.

Parameters
resPointer to the output matrix2i.
mPointer to the input matrix.

Definition at line 44 of file matrix2i_ptr.c.

References matrix2i::v.

Referenced by mat2i_transpose().