From e7420b24c30d9c25bdcc9369fb1ae7a409fda7d4 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 3 Mar 2021 00:07:16 +0000 Subject: Our own matrix rotations Simpler and faster than glm's as we don't need arbitrary axes. --- test/test-maths.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index a2e1953..b66b863 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -2,7 +2,9 @@ #include #include +#include #include +#include #include #include @@ -95,3 +97,30 @@ BOOST_AUTO_TEST_CASE(test_find_arcs_radius) { BOOST_CHECK_CLOSE(find_arcs_radius({10.32, 26.71}, {0.4, .92}, {2.92, 22.41}, {-0.89, -0.45}), 2.29, 1); } + +static void +compare_rotations(float a, const glm::vec3 & axis, glm::mat4 (*rotate_func)(float), std::string_view n) +{ + BOOST_TEST_CONTEXT(n) { + const auto g {glm::rotate(a, axis)}, ilt {rotate_func(a)}; + for (int c = 0; c < 4; c++) { + BOOST_TEST_CONTEXT(c) { + for (int r = 0; r < 4; r++) { + BOOST_TEST_CONTEXT(r) { + BOOST_CHECK_CLOSE(g[c][r], ilt[c][r], 0.0001); + } + } + } + } + } +} +const auto angs = boost::unit_test::data::make({pi, half_pi, two_pi, quarter_pi, -pi, -half_pi, -quarter_pi, 0.F}); +const auto rots = boost::unit_test::data::make>({ + {up, rotate_yaw, "yaw"}, + {west, rotate_pitch, "pitch"}, + {north, rotate_roll, "roll"}, +}); +BOOST_DATA_TEST_CASE(test_rotations, angs * rots, a, ax, func, n) +{ + compare_rotations(a, ax, func, n); +} -- cgit v1.2.3