math: fix adjoint of Matrix2 (#1676)

* math: fix adjoint of Matrix2

Fix the adjoint of the Matrix2x2 implementation in the math module. This
also fixes the calculation of the inverse which depends on the adjoint.

* update release notes
This commit is contained in:
konimarti
2024-12-13 11:16:47 +01:00
committed by GitHub
parent c9c3f33acc
commit 68c60f58c0
3 changed files with 12 additions and 2 deletions

View File

@@ -106,8 +106,17 @@ fn void test_mat2()
assert(calc.m == value.m);
}
fn void! test_mat2_inverse()
{
Matrix2 a = { 3, 5, 6, 2 };
Matrix2 a_inv = a.inverse()!;
double sum = ((double[<4>])a_inv.mul(a).m).sum();
assert(math::abs(sum - 2.0) < math::FLOAT_EPSILON,
"wrong inverse: sum of all elements should be 2, but got: %g", sum);
}
fn void test_vec3()
{
Vec3 cross = Vec3{2,3,4}.cross(Vec3{5,6,7});
assert(cross == Vec3{-3,6,-3});
}
}