From 838e5f77478e5648769439e191e3ff0a8e6405ab Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 22 Feb 2021 20:12:59 +0000 Subject: Add meandering support Add rail links between existing nodes and arbitrary points --- test/test-maths.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/test-maths.cpp') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index 49114da..d5848c6 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -74,3 +75,20 @@ BOOST_DATA_TEST_CASE(test_create_arc, BOOST_CHECK_CLOSE(arc.first, a.first, 1.F); BOOST_CHECK_CLOSE(arc.second, a.second, 1.F); } + +using fac = std::tuple; +BOOST_DATA_TEST_CASE(test_find_arc_centre, + boost::unit_test::data::make({ + {{2, 2}, pi, {3, 3}, half_pi, {3, 2}, true}, + {{2, 2}, pi, {1, 3}, -half_pi, {1, 2}, false}, + {{-1100, -1000}, pi, {-900, -800}, half_pi, {-900, -1000}, true}, + {{1100, 1000}, 0, {1050, 900}, pi + 0.92, {973, 1000}, true}, + {{1050, 900}, 0.92, {1000, 800}, pi, {1127, 800}, false}, + }), + s, es, e, ee, exp, lr) +{ + const auto c = find_arc_centre(s, es, e, ee); + BOOST_CHECK_CLOSE(exp.x, c.first.x, 1); + BOOST_CHECK_CLOSE(exp.y, c.first.y, 1); + BOOST_CHECK_EQUAL(lr, c.second); +} -- cgit v1.2.3