mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-27 17:28:41 +00:00
Fix random usage in matrix4 tests
This commit is contained in:
parent
1ceeea34f4
commit
5abf220979
1 changed files with 32 additions and 22 deletions
|
@ -85,11 +85,9 @@ SECTION("getScale") {
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("getRotationDegrees") {
|
SECTION("getRotationDegrees") {
|
||||||
auto test_rotation_degrees = [](v3f deg) {
|
auto test_rotation_degrees = [](v3f deg, v3f scale) {
|
||||||
matrix4 S;
|
matrix4 S;
|
||||||
Catch::Generators::RandomFloatingGenerator<f32> gen(0.1f, 10, Catch::getSeed());
|
S.setScale(scale);
|
||||||
S.setScale({gen.get(), gen.get(), gen.get()});
|
|
||||||
|
|
||||||
matrix4 R;
|
matrix4 R;
|
||||||
R.setRotationDegrees(deg);
|
R.setRotationDegrees(deg);
|
||||||
v3f rot = (R * S).getRotationDegrees();
|
v3f rot = (R * S).getRotationDegrees();
|
||||||
|
@ -98,14 +96,26 @@ SECTION("getRotationDegrees") {
|
||||||
CHECK(matrix_equals(R, B));
|
CHECK(matrix_equals(R, B));
|
||||||
};
|
};
|
||||||
SECTION("returns a rotation equivalent to the original rotation") {
|
SECTION("returns a rotation equivalent to the original rotation") {
|
||||||
test_rotation_degrees({100, 200, 300});
|
test_rotation_degrees({100, 200, 300}, v3f(1));
|
||||||
Catch::Generators::RandomFloatingGenerator<f32> gen(0, 360, Catch::getSeed());
|
Catch::Generators::RandomFloatingGenerator<f32> gen_angle(0, 360, Catch::getSeed());
|
||||||
|
Catch::Generators::RandomFloatingGenerator<f32> gen_scale(0.1f, 10, Catch::getSeed());
|
||||||
|
auto draw = [](auto gen) {
|
||||||
|
f32 f = gen.get();
|
||||||
|
gen.next();
|
||||||
|
return f;
|
||||||
|
};
|
||||||
|
auto draw_v3f = [&](auto gen) {
|
||||||
|
return v3f{draw(gen), draw(gen), draw(gen)};
|
||||||
|
};
|
||||||
for (int i = 0; i < 1000; ++i)
|
for (int i = 0; i < 1000; ++i)
|
||||||
test_rotation_degrees(v3f{gen.get(), gen.get(), gen.get()});
|
test_rotation_degrees(draw_v3f(gen_angle), draw_v3f(gen_scale));
|
||||||
for (f32 i = 0; i < 360; i += 90)
|
for (f32 i = 0; i < 360; i += 90)
|
||||||
for (f32 j = 0; j < 360; j += 90)
|
for (f32 j = 0; j < 360; j += 90)
|
||||||
for (f32 k = 0; k < 360; k += 90)
|
for (f32 k = 0; k < 360; k += 90) {
|
||||||
test_rotation_degrees({i, j, k});
|
for (int l = 0; l < 100; ++l) {
|
||||||
|
test_rotation_degrees({i, j, k}, draw_v3f(gen_scale));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue