Skip to content

Commit

Permalink
use Number instead of double for from_<angle> literal operator
Browse files Browse the repository at this point in the history
  • Loading branch information
SizzinSeal committed Dec 29, 2024
1 parent 6f3befe commit dcd93b0
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions include/units/Angle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ NEW_UNIT_LITERAL(AngularJerk, rpm3, rot / min / min / min)
// Standard orientation
constexpr Angle operator""_stRad(long double value) { return Angle(static_cast<double>(value)); }

constexpr Angle operator""_stRad(unsigned long long value) { return Angle(static_cast<double>(value)); }

constexpr Angle operator""_stDeg(long double value) { return static_cast<double>(value) * deg; }

constexpr Angle operator""_stDeg(unsigned long long value) { return static_cast<double>(value) * deg; }
Expand Down Expand Up @@ -99,27 +97,27 @@ static inline Angle constrainAngle180(Angle in) {

// Angle to/from operators
// Standard orientation
constexpr inline Angle from_stRad(double value) { return Angle(value); }
constexpr inline Angle from_stRad(Number value) { return Angle(value.internal()); }

constexpr inline double to_stRad(Angle quantity) { return quantity.internal(); }

constexpr inline Angle from_stDeg(double value) { return value * deg; }
constexpr inline Angle from_stDeg(Number value) { return value * deg; }

constexpr inline double to_stDeg(Angle quantity) { return quantity.convert(deg); }

constexpr inline Angle from_stRot(double value) { return value * rot; }
constexpr inline Angle from_stRot(Number value) { return value * rot; }

constexpr inline double to_stRot(Angle quantity) { return quantity.convert(rot); }

// Compass orientation
constexpr inline Angle from_cRad(double value) { return 90 * deg - Angle(value); }
constexpr inline Angle from_cRad(Number value) { return 90 * deg - Angle(value.internal()); }

constexpr inline double to_cRad(Angle quantity) { return quantity.internal(); }

constexpr inline Angle from_cDeg(double value) { return (90 - value) * deg; }
constexpr inline Angle from_cDeg(Number value) { return (90 - value.internal()) * deg; }

constexpr inline double to_cDeg(Angle quantity) { return (90 * deg - quantity).convert(deg); }

constexpr inline Angle from_cRot(double value) { return (90 - value) * deg; }
constexpr inline Angle from_cRot(Number value) { return (90 - value.internal()) * deg; }

constexpr inline double to_cRot(Angle quantity) { return (90 * deg - quantity).convert(rot); }

0 comments on commit dcd93b0

Please sign in to comment.