From 0aa665c3648d788755b00c9e431c872d57fddbb8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 25 Nov 2023 16:28:39 +0000 Subject: Model positions as integers Introduces test failure in arcs due to rounding, but I don't want to create a complicated fix as link positions are still floats and hopefully that'll go away... somehow --- test/test-maths.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'test/test-maths.cpp') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index 2560319..9eae918 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -196,12 +196,12 @@ BOOST_DATA_TEST_CASE(straight1, const TestLinkStraight l(v); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_EQUAL(p.pos, origin); + BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {origin}); BOOST_CHECK_EQUAL(p.rot, glm::vec3(0, angFor, 0)); } { const auto p = l.positionAt(0, 1); - BOOST_CHECK_EQUAL(p.pos, v); + BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {v}); BOOST_CHECK_EQUAL(p.rot, glm::vec3(0, angBack, 0)); } } @@ -231,12 +231,12 @@ BOOST_DATA_TEST_CASE(curve1, BOOST_CHECK_EQUAL(l.radius, 1.F); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_CLOSE_VEC(p.pos, origin); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angFor, 0)); } { const auto p = l.positionAt(0, 1); - BOOST_CHECK_CLOSE_VEC(p.pos, e1); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, e1); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBack, 0)); } } @@ -247,13 +247,13 @@ BOOST_DATA_TEST_CASE(curve1, { const auto p = l.positionAt(0, 0); const auto angForReversed = normalize(vector_yaw(origin - e1) * 2 - angFor); - BOOST_CHECK_CLOSE_VEC(p.pos, e1); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {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 - origin) * 2 - angBack); - BOOST_CHECK_CLOSE_VEC(p.pos, origin); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBackReversed, 0)); } } -- cgit v1.2.3 From 504d345e24e3be54d90f8bdd107c5bfbb38e57af Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 9 Dec 2023 12:04:07 +0000 Subject: Helper for testing integer vector approximations --- test/test-maths.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/test-maths.cpp') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index 9eae918..cc97250 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -236,8 +236,8 @@ BOOST_DATA_TEST_CASE(curve1, } { const auto p = l.positionAt(0, 1); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, e1); - BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBack, 0)); + BOOST_CHECK_CLOSE_VECI(RelativePosition3D {p.pos}, e1); + BOOST_CHECK_CLOSE_VECI(p.rot, glm::vec3(0, angBack, 0)); } } @@ -247,8 +247,8 @@ BOOST_DATA_TEST_CASE(curve1, { const auto p = l.positionAt(0, 0); const auto angForReversed = normalize(vector_yaw(origin - e1) * 2 - angFor); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, e1); - BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angForReversed, 0)); + BOOST_CHECK_CLOSE_VECI(RelativePosition3D {p.pos}, e1); + BOOST_CHECK_CLOSE_VECI(p.rot, glm::vec3(0, angForReversed, 0)); } { const auto p = l.positionAt(0, 1); -- cgit v1.2.3 From daed922f23daa8a8e2659d8aea7864cccd5e08c7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 11 Dec 2023 20:11:23 +0000 Subject: Integer camera --- test/test-maths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/test-maths.cpp') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index cc97250..3f8c2a0 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -261,7 +261,7 @@ BOOST_DATA_TEST_CASE(curve1, BOOST_AUTO_TEST_CASE(camera_clicks) { - Camera camera {::origin, ::half_pi, 1.25F, .1F, 10000.F}; + Camera camera {::origin, ::half_pi, 1.25F, 1000, 10000000}; constexpr float centre {0.5F}, right {0.9F}, left {0.1F}, top {1.F}, bottom {0.F}; camera.setForward(::north); BOOST_CHECK_EQUAL(camera.unProject({centre, centre}).start, ::origin); -- cgit v1.2.3 From dc672a3488ec1d665fa898ced401e40ebc609bf8 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 29 Dec 2023 16:46:48 +0000 Subject: Templatise functions in maths.h using PositionND --- test/test-maths.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/test-maths.cpp') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index 3f8c2a0..ede884d 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -171,7 +171,8 @@ BOOST_DATA_TEST_CASE(test_find_arc_centre, 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); + BOOST_CHECK_CLOSE( + find_arcs_radius(RelativePosition2D {10.32, 26.71}, {0.4, .92}, {2.92, 22.41}, {-0.89, -0.45}), 2.29, 1); } struct TestLinkStraight : public LinkStraight { -- cgit v1.2.3 From 69e6b7d2d349dcc42d2d415a72181ba729d5a19d Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 1 Jan 2024 15:53:54 +0000 Subject: Remove more use of legacy types --- test/test-maths.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/test-maths.cpp') diff --git a/test/test-maths.cpp b/test/test-maths.cpp index ede884d..b363c17 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -177,7 +177,7 @@ BOOST_AUTO_TEST_CASE(test_find_arcs_radius) struct TestLinkStraight : public LinkStraight { explicit TestLinkStraight(glm::vec3 v) : - Link {{std::make_shared(origin), vector_yaw(v)}, {std::make_shared(v), vector_yaw(-v)}, + Link {{std::make_shared(Position3D {}), vector_yaw(v)}, {std::make_shared(v), vector_yaw(-v)}, glm::length(v)} { } @@ -197,7 +197,7 @@ BOOST_DATA_TEST_CASE(straight1, const TestLinkStraight l(v); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {origin}); + BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {}); BOOST_CHECK_EQUAL(p.rot, glm::vec3(0, angFor, 0)); } { @@ -228,11 +228,11 @@ BOOST_DATA_TEST_CASE(curve1, e1, ctr, angFor, angBack) { { // One-way... - const TestLinkCurve l(origin, e1, ctr); + const TestLinkCurve l({}, e1, ctr); BOOST_CHECK_EQUAL(l.radius, 1.F); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, RelativePosition3D {}); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angFor, 0)); } { @@ -243,18 +243,18 @@ BOOST_DATA_TEST_CASE(curve1, } { // The other way... - const TestLinkCurve l(e1, origin, ctr); + const TestLinkCurve l(e1, {}, ctr); BOOST_CHECK_EQUAL(l.radius, 1.F); { const auto p = l.positionAt(0, 0); - const auto angForReversed = normalize(vector_yaw(origin - e1) * 2 - angFor); + const auto angForReversed = normalize(vector_yaw(-e1) * 2 - angFor); BOOST_CHECK_CLOSE_VECI(RelativePosition3D {p.pos}, e1); BOOST_CHECK_CLOSE_VECI(p.rot, glm::vec3(0, angForReversed, 0)); } { const auto p = l.positionAt(0, 1); - const auto angBackReversed = normalize(vector_yaw(e1 - origin) * 2 - angBack); - BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); + const auto angBackReversed = normalize(vector_yaw(e1) * 2 - angBack); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, Position3D {}); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBackReversed, 0)); } } @@ -262,10 +262,10 @@ BOOST_DATA_TEST_CASE(curve1, BOOST_AUTO_TEST_CASE(camera_clicks) { - Camera camera {::origin, ::half_pi, 1.25F, 1000, 10000000}; + Camera camera {{}, ::half_pi, 1.25F, 1000, 10000000}; constexpr float centre {0.5F}, right {0.9F}, left {0.1F}, top {1.F}, bottom {0.F}; camera.setForward(::north); - BOOST_CHECK_EQUAL(camera.unProject({centre, centre}).start, ::origin); + BOOST_CHECK_EQUAL(camera.unProject({centre, centre}).start, RelativePosition3D {}); BOOST_CHECK_CLOSE_VEC(camera.unProject({centre, centre}).direction, ::north); BOOST_CHECK_CLOSE_VEC(camera.unProject({left, centre}).direction, glm::normalize(::north + ::west)); BOOST_CHECK_CLOSE_VEC(camera.unProject({right, centre}).direction, glm::normalize(::north + ::east)); -- cgit v1.2.3