60 static_assert(std::numeric_limits<T>::is_integer &&
61 std::numeric_limits<T>::is_signed,
62 "T must be a signed integer type");
87 explicit Angle(
const T value = 0) : value_(value) {}
90 static constexpr T
RAW_PI = std::numeric_limits<T>::min();
94 static_cast<T
>(-(std::numeric_limits<T>::min() >> 1));
112 T
raw()
const {
return value_; }
132 value_ =
static_cast<T
>(value_ + other.value_);
142 value_ =
static_cast<T
>(value_ - other.value_);
151 template <
typename Scalar>
153 value_ =
static_cast<T
>(std::lround(value_ * s));
162 template <
typename Scalar>
164 value_ =
static_cast<T
>(std::lround(value_ / s));
207template <
typename T,
typename Scalar>
219template <
typename T,
typename Scalar>
231template <
typename T,
typename Scalar>
245 return static_cast<double>(lhs.
raw()) / rhs.
raw();
256 return lhs.
raw() == rhs.
raw();
267 return !(lhs == rhs);
The Angle class uses an integer to represent an angle, and supports commonly-used operations such as ...
Angle operator/=(Scalar s)
Divides angle by scalar
static constexpr double RAD_TO_RAW
Used for converting angle units
static Angle from_deg(const double value)
Constructs an Angle object from an angle in degrees (factory).
static constexpr double RAW_TO_DEG
Used for converting angle units
T raw() const
Getter of value_.
Angle operator-=(Angle other)
Subtracts another angle from the current one.
static Angle from_rad(const double value)
Constructs an Angle object from an angle in radians (factory).
double to_rad() const
Converts the internal representation to radians.
static constexpr T RAW_PI
Internal representation of pi
double to_deg() const
Converts the internal representation to degrees.
static constexpr T RAW_PI_2
Internal representation of pi/2
Angle operator+=(Angle other)
Sums another angle to the current one.
Angle operator*=(Scalar s)
Multiplies angle by scalar
static constexpr double RAW_TO_RAD
Used for converting angle units
static constexpr double DEG_TO_RAW
Used for converting angle units
Angle(const T value=0)
Constructs an Angle object from raw internal value.
bool operator==(Angle< T > lhs, Angle< T > rhs)
Tests two Angle objects for equality
Angle< T > operator-(Angle< T > lhs, Angle< T > rhs)
Subtracts two angles
Angle< T > operator/(Angle< T > lhs, Scalar rhs)
Divides an Angle by a scalar
Angle< T > operator+(Angle< T > lhs, Angle< T > rhs)
Sums two angles
bool operator!=(Angle< T > lhs, Angle< T > rhs)
Tests two Angle objects for inequality
Angle< T > operator*(Angle< T > lhs, Scalar rhs)
Multiplies an Angle by a scalar