3 #include "../../catch2/catch.hpp"
7 #define MX_NO_ERROR_REPORTS
9 #include "../../../include/math/geo.hpp"
16 SCENARIO(
"Verify compilation and calculations of math::angleMod",
"[math::angleMod]" )
18 GIVEN(
"angles in degrees")
20 WHEN(
"positive angle, no changes")
22 double q = mx::math::angleMod<mx::math::degreesT<double>>(43.2);
24 REQUIRE_THAT(q, Catch::Matchers::WithinRel(43.2));
27 WHEN(
"positive angle, no changes")
29 double q = mx::math::angleMod<mx::math::degreesT<double>>(353.2);
31 REQUIRE_THAT(q, Catch::Matchers::WithinRel(353.2));
34 WHEN(
"positive angle, exactly 360")
36 double q = mx::math::angleMod<mx::math::degreesT<double>>(360.0);
38 REQUIRE_THAT(q, Catch::Matchers::WithinRel(0.0));
41 WHEN(
"positive angle, mod needed")
43 double q = mx::math::angleMod<mx::math::degreesT<double>>(362.0);
45 REQUIRE_THAT(q, Catch::Matchers::WithinRel(2.0));
49 GIVEN(
"angles in radians")
51 WHEN(
"positive angle, no changes")
53 double q = mx::math::angleMod<mx::math::radiansT<double>>(
mx::math::dtor(43.2));
58 WHEN(
"positive angle, no changes")
60 double q = mx::math::angleMod<mx::math::radiansT<double>>(
mx::math::dtor(353.2));
62 REQUIRE_THAT(q, Catch::Matchers::WithinRel(
mx::math::dtor(353.2)));
65 WHEN(
"positive angle, exactly 2pi")
67 double q = mx::math::angleMod<mx::math::radiansT<double>>(
mx::math::dtor(360.0));
72 WHEN(
"positive angle, mod needed")
74 double q = mx::math::angleMod<mx::math::radiansT<double>>(
mx::math::dtor(362.0));
86 SCENARIO(
"Verify compilation and calculations of math::angleDiff",
"[math::angleDiff]" )
88 GIVEN(
"angles in degrees")
90 WHEN(
"positive, first angle is 0, not crossing 180/360")
92 double q = mx::math::angleDiff<mx::math::degreesT<double>>(0.0,43.2);
94 REQUIRE_THAT(q, Catch::Matchers::WithinRel(43.2));
97 WHEN(
"negative, second angle is 0, not crossing 180/360")
99 double q = mx::math::angleDiff<mx::math::degreesT<double>>(43.2,0.0);
101 REQUIRE_THAT(q, Catch::Matchers::WithinRel(-43.2));
104 WHEN(
"positive, first angle is 360, not crossing 180/360")
106 double q = mx::math::angleDiff<mx::math::degreesT<double>>(360.0,43.2);
108 REQUIRE_THAT(q, Catch::Matchers::WithinRel(43.2));
111 WHEN(
"negative, second angle is 3600, not crossing 180/360")
113 double q = mx::math::angleDiff<mx::math::degreesT<double>>(43.2,360.0);
115 REQUIRE_THAT(q, Catch::Matchers::WithinRel(-43.2));
118 WHEN(
"positive, crossing 360")
120 double q = mx::math::angleDiff<mx::math::degreesT<double>>(340.0,23.2);
122 REQUIRE_THAT(q, Catch::Matchers::WithinRel(43.2));
125 WHEN(
"negative, crossing 180/360")
127 double q = mx::math::angleDiff<mx::math::degreesT<double>>(23.2,340.0);
129 REQUIRE_THAT(q, Catch::Matchers::WithinRel(-43.2));
132 WHEN(
"positive, crossing 180")
134 double q = mx::math::angleDiff<mx::math::degreesT<double>>(160.0,206.2);
136 REQUIRE_THAT(q, Catch::Matchers::WithinRel(46.2));
139 WHEN(
"negative, crossing 180")
141 double q = mx::math::angleDiff<mx::math::degreesT<double>>(206.2,160.0);
143 REQUIRE_THAT(q, Catch::Matchers::WithinRel(-46.2));
147 GIVEN(
"angles in radians")
149 WHEN(
"positive, first angle is 0, not crossing pi/2pi")
151 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(0.0),mx::math::dtor<double>(43.2));
153 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(43.2)));
156 WHEN(
"negative, second angle is 0, not crossing pi/2pi")
158 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(43.2),mx::math::dtor<double>(0.0));
160 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(-43.2)));
163 WHEN(
"positive, first angle is 360, not crossing pi/2pi")
165 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(360.0),mx::math::dtor<double>(43.2));
167 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(43.2)));
170 WHEN(
"negative, second angle is 3600, not crossing pi/2pi")
172 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(43.2),mx::math::dtor<double>(360.0));
174 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(-43.2)));
177 WHEN(
"positive, crossing 2pi")
179 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(340.0),mx::math::dtor<double>(23.2));
181 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(43.2)));
184 WHEN(
"negative, crossing 2pi")
186 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(23.2),mx::math::dtor<double>(340.0));
188 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(-43.2)));
191 WHEN(
"positive, crossing pi")
193 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(160.0),mx::math::dtor<double>(206.2));
195 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(46.2)));
198 WHEN(
"negative, crossing pi")
200 double q = mx::math::angleDiff<mx::math::radiansT<double>>(mx::math::dtor<double>(206.2),mx::math::dtor<double>(160.0));
202 REQUIRE_THAT(q, Catch::Matchers::WithinRel(mx::math::dtor<double>(-46.2)));
SCENARIO("Verify compilation and calculations of math::angleMod", "[math::angleMod]")
realT dtor(realT q)
Convert from degrees to radians.