Add rigid inverse for 3x3 and 4x4 matrices
All checks were successful
CI / build-and-analyze (push) Successful in 1m22s

This commit is contained in:
2026-07-21 12:08:16 +03:00
parent 57a1be7924
commit 2c7a7c4c4a
3 changed files with 29 additions and 1 deletions

14
Mat3f.c
View File

@@ -83,7 +83,7 @@ float CgeMat3fDet(const float in[9]) {
int CgeMat3fInverse(const float in[9], float out[9]) {
float a, b, c, det;
float tmp[16];
float tmp[9];
a = in[4] * in[8] - in[7] * in[5];
b = in[1] * in[8] - in[7] * in[2];
@@ -121,6 +121,18 @@ int CgeMat3fInverse(const float in[9], float out[9]) {
return 1;
}
void CgeMat3fInverseRigid(const float in[9], float out[9]) {
float tmp[9];
CgeMat3fIdentity(tmp);
tmp[0] = in[0]; tmp[1] = in[3];
tmp[3] = in[1]; tmp[4] = in[4];
tmp[6] = -(in[6] * tmp[0] + in[7] * tmp[3]);
tmp[7] = -(in[6] * tmp[1] + in[7] * tmp[4]);
memcpy(out, tmp, sizeof(tmp));
}
void CgeMat3fFromScale(float x, float y, float out[9]) {
CgeMat3fIdentity(out);
out[0] = x;