Vecmat 0.2.3
C math and linear algebra library for 2D/3D graphics, physics, and science.
Loading...
Searching...
No Matches
matrix2i.c
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025-2026 Igal Alkon
2// SPDX-FileCopyrightText: 2026 ALKONTEK <git@alkontek.com>
3// SPDX-License-Identifier: BSD-3-Clause
4
5#include <vecmat.h>
6
15{
16 matrix2i res;
18 return res;
19}
20
31{
32 matrix2i res;
33 mat2i_mul_ptr(&res, &a, &b);
34 return res;
35}
36
46{
47 matrix2i res;
48 mat2i_transpose_ptr(&res, &m);
49 return res;
50}
51
61{
62 matrix2i res;
63 mat2i_inverse_ptr(&res, &m);
64 return res;
65}
66
74{
75 return m.v[0] * m.v[3] - m.v[1] * m.v[2];
76}
77
88{
89 vector2i res;
90 mat2i_mul_vec2i_ptr(&res, &m, &v);
91 return res;
92}
matrix2i mat2i_identity(void)
Constructs the 2x2 integer identity matrix.
Definition matrix2i.c:14
matrix2i mat2i_mul(const matrix2i a, const matrix2i b)
Multiplies two 2x2 integer matrices (a * b).
Definition matrix2i.c:30
vector2i mat2i_mul_vec2i(const matrix2i m, const vector2i v)
Multiplies a 2x2 integer matrix by a vector2i.
Definition matrix2i.c:87
matrix2i mat2i_transpose(const matrix2i m)
Computes the transpose of a 2x2 integer matrix.
Definition matrix2i.c:45
vm_int_t mat2i_determinant(const matrix2i m)
Calculates the determinant of the given 2x2 integer matrix.
Definition matrix2i.c:73
matrix2i mat2i_inverse(const matrix2i m)
Computes the inverse of a 2x2 integer matrix.
Definition matrix2i.c:60
vm_int_t v[VECMAT_MAT2_SIZE]
Definition vecmat.h:294
void mat2i_transpose_ptr(matrix2i *res, const matrix2i *m)
Computes the transpose of the input integer 2x2 matrix and stores in res.
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_mul_vec2i_ptr(vector2i *res, const matrix2i *m, const vector2i *v)
Multiplies a 2x2 integer matrix by a vector2i.
void mat2i_inverse_ptr(matrix2i *res, const matrix2i *m)
Computes the inverse of the input integer 2x2 matrix and stores in res.
void mat2i_identity_ptr(matrix2i *res)
Initializes the integer 2x2 matrix to identity (diagonal 1, others 0).
int8_t vm_int_t
Definition vecmat.h:103