File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,29 @@ class CAngle {
6868 constexpr CAngle (double value) : value(value) {}
6969};
7070
71+ /* *
72+ * @brief Angle Distance class
73+ *
74+ * yet another helper class to manage the compass angle fiasco (it's getting nuked on May 15 2025)
75+ *
76+ * consider the following:
77+ * Angle exitRange1 = 0_cDeg;
78+ * Angle exitRange2 = 0_stDeg;
79+ *
80+ * It is expected that exitRange1 and exitRange2 is equal to each other.
81+ * However, this is not the case. 0_cDeg gets converted to 90_stDeg
82+ * implicitly. So, yet another helper class is necessary (hooray)
83+ *
84+ */
85+ class AngleDistance : public Angle {
86+ public:
87+ explicit constexpr AngleDistance (double value) : Angle(fabs(value)) {}
88+
89+ constexpr AngleDistance (Angle value) : Angle(units::abs(value)) {}
90+
91+ constexpr AngleDistance (CAngle value) : Angle(units::abs(Angle(value) - Angle(M_PI_2))) {}
92+ };
93+
7194constexpr bool operator ==(Angle lhs, CAngle rhs) { return lhs == Angle (rhs); }
7295
7396constexpr Angle rad = Angle(1.0 );
Original file line number Diff line number Diff line change @@ -45,14 +45,21 @@ void initialize() {
4545 units::Vector2D<Number> v2e = units::V2Position (2_in, 2_in) / 2_in;
4646}
4747
48- void angleTests () {
48+ constexpr void angleTests () {
4949 static_assert (+15_cDeg == 75_stDeg);
5050 static_assert (to_stDeg (-+15_cDeg) == to_stDeg (105_stDeg));
5151 static_assert (r2i (to_stDeg (30_cDeg)) == r2i (to_stDeg (60_stDeg)));
5252 static_assert (r2i (to_stDeg (+0_cDeg)) == r2i (to_stDeg (90_stDeg)));
5353 Angle a = 2_cDeg;
5454}
5555
56+ constexpr void angleDistanceTests () {
57+ // static_assert(r2i(to_stDeg(AngleDistance(-15_cDeg))) == r2i(to_stDeg(AngleDistance(+15_stDeg))));
58+ Angle a = 2_stDeg + AngleDistance (15_stDeg);
59+ Angle b = AngleDistance (15_stDeg) + 2_stDeg;
60+ Angle c = 2_stDeg + AngleDistance (15_cDeg);
61+ }
62+
5663constexpr Number numAssignmentTests () {
5764 Number n = 1_num; // 1
5865 n += 2 ; // 3
@@ -73,7 +80,6 @@ constexpr double doubleAssignmentTests() {
7380 return d;
7481}
7582
76-
7783void numberOperatorTests () {
7884 static_assert (1_num + 2 == 3 );
7985 static_assert (1 + 2_num <= 3 );
You can’t perform that action at this time.
0 commit comments