summaryrefslogtreecommitdiff
path: root/test/test-maths.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-maths.cpp')
-rw-r--r--test/test-maths.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/test/test-maths.cpp b/test/test-maths.cpp
index ccfb113..b9d08bb 100644
--- a/test/test-maths.cpp
+++ b/test/test-maths.cpp
@@ -107,9 +107,9 @@ const auto angs = boost::unit_test::data::make({pi, half_pi, two_pi, quarter_pi,
* boost::unit_test::data::make(0);
const auto random_angs = boost::unit_test::data::random(-two_pi, two_pi) ^ boost::unit_test::data::xrange(1000);
const auto rots = boost::unit_test::data::make<std::tuple<glm::vec3, glm::mat4 (*)(float), std::string_view>>({
- {down, rotate_yaw, "yaw"},
- {east, rotate_pitch, "pitch"},
- {north, rotate_roll, "roll"},
+ {down, rotate_yaw<4>, "yaw"},
+ {east, rotate_pitch<4>, "pitch"},
+ {north, rotate_roll<4>, "roll"},
});
BOOST_DATA_TEST_CASE(test_rotations, (angs + random_angs) * rots, angle, ai, axis, ilt_func, name)
@@ -247,13 +247,13 @@ BOOST_DATA_TEST_CASE(curve1,
BOOST_CHECK_EQUAL(l.radius, 1.F);
{
const auto p = l.positionAt(0, 0);
- const auto angForReversed = normalize(vector_yaw(-e1) * 2 - angFor);
+ const auto angForReversed = normalize(vector_yaw(difference({}, e1)) * 2 - angFor);
BOOST_CHECK_CLOSE_VECI(p.pos, e1);
BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angForReversed, 0));
}
{
const auto p = l.positionAt(0, 1);
- const auto angBackReversed = normalize(vector_yaw(e1) * 2 - angBack);
+ const auto angBackReversed = normalize(vector_yaw(difference(e1, {})) * 2 - angBack);
BOOST_CHECK_CLOSE_VECI(p.pos, GlobalPosition3D {});
BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBackReversed, 0));
}
@@ -333,3 +333,11 @@ BOOST_DATA_TEST_CASE(rayLineDistance,
BOOST_CHECK_LE(Ray<RelativePosition3D>(c, direction).distanceToLine(n1, n2), 0.01F);
}
}
+
+static_assert(linesIntersectAt(glm::ivec2 {10, 10}, {40, 40}, {10, 80}, {20, 40}).value().x == 24);
+static_assert(linesIntersectAt(glm::vec2 {10, 10}, {40, 40}, {10, 80}, {20, 40}).value().y == 24);
+static_assert(linesIntersectAt(GlobalPosition2D {311000100, 491100100}, {311050000, 491150000}, {312000100, 491200100},
+ {311000100, 491100100})
+ .value()
+ == GlobalPosition2D {311000100, 491100100});
+static_assert(!linesIntersectAt(glm::dvec2 {0, 1}, {0, 4}, {1, 8}, {1, 4}).has_value());