mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Extend quaternion tests
This commit is contained in:
parent
3ae1fd459a
commit
1ceeea34f4
1 changed files with 35 additions and 18 deletions
|
@ -27,7 +27,24 @@ SECTION("equivalence to euler rotations") {
|
|||
CHECK(matrix_equals(R, R2));
|
||||
};
|
||||
|
||||
test_rotation({100, 200, 300});
|
||||
Catch::Generators::RandomFloatingGenerator<f32> gen(0.0f, 2 * core::PI, Catch::getSeed());
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
test_rotation(v3f{gen.get(), gen.get(), gen.get()});
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int k = 0; k < 4; k++)
|
||||
test_rotation(core::PI / 4.0f * v3f(i, j, k));
|
||||
}
|
||||
|
||||
SECTION("equivalence to rotation matrices") {
|
||||
auto test_rotation = [](v3f rad) {
|
||||
matrix4 R;
|
||||
R.setRotationRadians(rad);
|
||||
matrix4 R2;
|
||||
core::quaternion(R).getMatrix(R2);
|
||||
CHECK(matrix_equals(R, R2));
|
||||
};
|
||||
|
||||
Catch::Generators::RandomFloatingGenerator<f32> gen(0.0f, 2 * core::PI, Catch::getSeed());
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
test_rotation(v3f{gen.get(), gen.get(), gen.get()});
|
||||
|
|
Loading…
Add table
Reference in a new issue