summaryrefslogtreecommitdiff
path: root/test/test-geoData.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-04-02 20:37:23 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2024-04-02 20:37:23 +0100
commit2865ce32bc00e6c05c2686215880085b23aecabf (patch)
tree30938488c959f31e7b162cde4070c8c1289a544e /test/test-geoData.cpp
parentBoundary edge and one time split with repeated 4-way split of large faces (diff)
downloadilt-2865ce32bc00e6c05c2686215880085b23aecabf.tar.bz2
ilt-2865ce32bc00e6c05c2686215880085b23aecabf.tar.xz
ilt-2865ce32bc00e6c05c2686215880085b23aecabf.zip
Tests for triangle helpers
Diffstat (limited to 'test/test-geoData.cpp')
-rw-r--r--test/test-geoData.cpp17
1 files changed, 17 insertions, 0 deletions
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<GlobalPosition2D, GlobalPosition2D, int>;
BOOST_DATA_TEST_CASE(findEntries,