Skip to content

Commit

Permalink
Merge pull request #9 from 5150VEX/error-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Aang099 authored Jun 20, 2024
2 parents 6b12ca0 + b905a32 commit 2391a94
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 151 deletions.
40 changes: 20 additions & 20 deletions include/units/Angle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ constexpr Angle rad = Angle(1.0);
constexpr Angle deg = Angle(M_PI / 180);
constexpr Angle rot = Angle(M_TWOPI);

NEW_QUANTITY(AngularVelocity, radps, 0, 0, -1, 0, 1, 0, 0, 0)
NEW_QUANTITY_VALUE(AngularVelocity, degps, deg / sec)
NEW_QUANTITY_VALUE(AngularVelocity, rps, rot / sec)
NEW_QUANTITY_VALUE(AngularVelocity, rpm, rot / min)
NEW_UNIT(AngularVelocity, radps, 0, 0, -1, 0, 1, 0, 0, 0)
NEW_UNIT_LITERAL(AngularVelocity, degps, deg / sec)
NEW_UNIT_LITERAL(AngularVelocity, rps, rot / sec)
NEW_UNIT_LITERAL(AngularVelocity, rpm, rot / min)

NEW_QUANTITY(AngularAcceleration, radps2, 0, 0, -2, 0, 1, 0, 0, 0)
NEW_QUANTITY_VALUE(AngularAcceleration, degps2, deg / sec / sec)
NEW_QUANTITY_VALUE(AngularAcceleration, rps2, rot / sec / sec)
NEW_QUANTITY_VALUE(AngularAcceleration, rpm2, rot / min / min)
NEW_UNIT(AngularAcceleration, radps2, 0, 0, -2, 0, 1, 0, 0, 0)
NEW_UNIT_LITERAL(AngularAcceleration, degps2, deg / sec / sec)
NEW_UNIT_LITERAL(AngularAcceleration, rps2, rot / sec / sec)
NEW_UNIT_LITERAL(AngularAcceleration, rpm2, rot / min / min)

NEW_QUANTITY(AngularJerk, radps3, 0, 0, -3, 0, 1, 0, 0, 0)
NEW_QUANTITY_VALUE(AngularJerk, rps3, rot / sec / sec / sec)
NEW_QUANTITY_VALUE(AngularJerk, rpm3, rot / min / min / min)
NEW_UNIT(AngularJerk, radps3, 0, 0, -3, 0, 1, 0, 0, 0)
NEW_UNIT_LITERAL(AngularJerk, rps3, rot / sec / sec / sec)
NEW_UNIT_LITERAL(AngularJerk, rpm3, rot / min / min / min)

// Angle declaration operators
constexpr Angle operator""_stDeg(long double value) { return static_cast<double>(value) * deg; }
Expand All @@ -42,20 +42,20 @@ constexpr Angle operator""_cRad(unsigned long long value) { return 90_stDeg - An

// Angle functions
namespace units {
constexpr Number sin(const Angle& rhs) { return Number(std::sin(rhs.val())); }
constexpr Number sin(const Angle& rhs) { return Number(std::sin(rhs.internal())); }

constexpr Number cos(const Angle& rhs) { return Number(std::cos(rhs.val())); }
constexpr Number cos(const Angle& rhs) { return Number(std::cos(rhs.internal())); }

constexpr Number tan(const Angle& rhs) { return Number(std::tan(rhs.val())); }
constexpr Number tan(const Angle& rhs) { return Number(std::tan(rhs.internal())); }

template <isQuantity Q> constexpr Angle asin(const Q& rhs) { return Angle(std::asin(rhs.val())); }
template <isQuantity Q> constexpr Angle asin(const Q& rhs) { return Angle(std::asin(rhs.internal())); }

template <isQuantity Q> constexpr Angle acos(const Q& rhs) { return Angle(std::acos(rhs.val())); }
template <isQuantity Q> constexpr Angle acos(const Q& rhs) { return Angle(std::acos(rhs.internal())); }

template <isQuantity Q> constexpr Angle atan(const Q& rhs) { return Angle(std::atan(rhs.val())); }
template <isQuantity Q> constexpr Angle atan(const Q& rhs) { return Angle(std::atan(rhs.internal())); }

template <isQuantity Q> constexpr Angle atan2(const Q& lhs, const Q& rhs) {
return Angle(std::atan2(lhs.val(), rhs.val()));
return Angle(std::atan2(lhs.internal(), rhs.internal()));
}

static inline Angle constrainAngle360(Angle in) { return mod(in, rot); }
Expand All @@ -69,15 +69,15 @@ static inline Angle constrainAngle180(Angle in) {
// Angle to/from operators
constexpr inline Angle from_sRad(double value) { return Angle(value); }

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

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

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

constexpr inline Angle from_cRad(double value) { return 90 * deg - Angle(value); }

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

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

Expand Down
4 changes: 2 additions & 2 deletions include/units/Vector2D.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ template <isQuantity T> class Vector2D {
* @param other the vector to calculate the dot product with
* @return R the dot product
*/
template <isQuantity Q, isQuantity R = QMultiplication<T, Q>> R dot(Vector2D<Q>& other) {
template <isQuantity Q, isQuantity R = Multiplied<T, Q>> R dot(Vector2D<Q>& other) {
return (x * other.getX()) + (y * other.getY());
}

Expand All @@ -215,7 +215,7 @@ template <isQuantity T> class Vector2D {
* @param other the vector to calculate the cross product with
* @return R the cross product
*/
template <isQuantity Q, isQuantity R = QMultiplication<T, Q>> R cross(Vector2D<Q>& other) {
template <isQuantity Q, isQuantity R = Multiplied<T, Q>> R cross(Vector2D<Q>& other) {
return (x * other.getY()) - (y * other.getX());
}

Expand Down
Loading

0 comments on commit 2391a94

Please sign in to comment.