mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
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:
@@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user