mirror of
https://github.com/minetest/minetest.git
synced 2025-03-06 20:48:40 +01:00
Add test for matrix4::getRotationDegrees
This commit is contained in:
parent
58ad604a4b
commit
0e86366324
1 changed files with 26 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
|||
// SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
#include "catch.h"
|
||||
#include "catch_amalgamated.hpp"
|
||||
#include "irrMath.h"
|
||||
#include "matrix4.h"
|
||||
#include "irr_v3d.h"
|
||||
|
@ -83,4 +84,29 @@ SECTION("getScale") {
|
|||
}
|
||||
}
|
||||
|
||||
SECTION("getRotationDegrees") {
|
||||
auto test_rotation_degrees = [](v3f deg) {
|
||||
matrix4 S;
|
||||
Catch::Generators::RandomFloatingGenerator<f32> gen(0.1f, 10, Catch::getSeed());
|
||||
S.setScale({gen.get(), gen.get(), gen.get()});
|
||||
|
||||
matrix4 R;
|
||||
R.setRotationDegrees(deg);
|
||||
v3f rot = (R * S).getRotationDegrees();
|
||||
matrix4 B;
|
||||
B.setRotationDegrees(rot);
|
||||
CHECK(matrix_equals(R, B));
|
||||
};
|
||||
SECTION("returns a rotation equivalent to the original rotation") {
|
||||
test_rotation_degrees({100, 200, 300});
|
||||
Catch::Generators::RandomFloatingGenerator<f32> gen(0, 360, Catch::getSeed());
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
test_rotation_degrees(v3f{gen.get(), gen.get(), gen.get()});
|
||||
for (f32 i = 0; i < 360; i += 90)
|
||||
for (f32 j = 0; j < 360; j += 90)
|
||||
for (f32 k = 0; k < 360; k += 90)
|
||||
test_rotation_degrees({i, j, k});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue