From 2865ce32bc00e6c05c2686215880085b23aecabf Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 2 Apr 2024 20:37:23 +0100 Subject: Tests for triangle helpers --- test/test-geoData.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 2d6b1aa..0a2de8d 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -192,6 +192,23 @@ BOOST_DATA_TEST_CASE(walkTerrainUntil, BOOST_CHECK_EQUAL_COLLECTIONS(visited.begin(), visited.end(), visits.begin(), visits.end()); } +BOOST_AUTO_TEST_CASE(triangle_helpers) +{ + constexpr static GeoData::Triangle<3> t {{0, 0, 0}, {5, 0, 0}, {5, 5, 0}}; + + BOOST_CHECK_EQUAL(t.nnormal(), up); + BOOST_CHECK_CLOSE(t.angle(0), quarter_pi, 0.01F); + BOOST_CHECK_CLOSE(t.angleAt({0, 0, 0}), quarter_pi, 0.01F); + BOOST_CHECK_CLOSE(t.angle(1), half_pi, 0.01F); + BOOST_CHECK_CLOSE(t.angleAt({5, 0, 0}), half_pi, 0.01F); + BOOST_CHECK_CLOSE(t.angle(2), quarter_pi, 0.01F); + BOOST_CHECK_CLOSE(t.angleAt({5, 5, 0}), quarter_pi, 0.01F); + + BOOST_CHECK_CLOSE(t.angleAt({0, 1, 0}), 0.F, 0.01F); + + BOOST_CHECK_CLOSE(t.area(), 12.5F, 0.01F); +} + using FindEntiesData = std::tuple; BOOST_DATA_TEST_CASE(findEntries, -- cgit v1.2.3