60 static_assert(std::numeric_limits<T>::is_integer &&
61 std::numeric_limits<T>::is_signed,
62 "T must be a signed integer type");
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));
183 template <
typename T>
195 template <
typename T>
207 template <
typename T,
typename Scalar>
219 template <
typename T,
typename Scalar>
231 template <
typename T,
typename Scalar>
243 template <
typename T>
245 return static_cast<double>(lhs.
raw()) / rhs.
raw();
254 template <
typename T>
256 return lhs.
raw() == rhs.
raw();
265 template <
typename T>
267 return !(lhs == rhs);
static constexpr double DEG_TO_RAW
Used for converting angle units.
Definition: angle.h:97
Angle operator-=(Angle other)
Subtracts another angle from the current one.
Definition: angle.h:141
Angle operator/=(Scalar s)
Divides angle by scalar.
Definition: angle.h:163
double to_rad() const
Converts the internal representation to radians.
Definition: angle.h:124
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
static Angle from_deg(const double value)
Constructs an Angle object from an angle in degrees (factory).
Definition: angle.h:69
Angle< T > operator*(Angle< T > lhs, Scalar rhs)
Multiplies an Angle by a scalar.
Definition: angle.h:208
static constexpr double RAW_TO_RAD
Used for converting angle units.
Definition: angle.h:106
Angle< T > operator-(Angle< T > lhs, Angle< T > rhs)
Subtracts two angles.
Definition: angle.h:196
The Angle class uses an integer to represent an angle, and supports commonly-used operations such as ...
Definition: angle.h:58
Angle< T > operator/(Angle< T > lhs, Scalar rhs)
Divides an Angle by a scalar.
Definition: angle.h:232
static constexpr T RAW_PI
Internal representation of pi.
Definition: angle.h:90
static constexpr double RAW_TO_DEG
Used for converting angle units.
Definition: angle.h:103
bool operator!=(Angle< T > lhs, Angle< T > rhs)
Tests two Angle objects for inequality.
Definition: angle.h:266
T raw() const
Getter of value_.
Definition: angle.h:112
static constexpr double RAD_TO_RAW
Used for converting angle units.
Definition: angle.h:100
double to_deg() const
Converts the internal representation to degrees.
Definition: angle.h:118
Angle< T > operator+(Angle< T > lhs, Angle< T > rhs)
Sums two angles.
Definition: angle.h:184
static Angle from_rad(const double value)
Constructs an Angle object from an angle in radians (factory).
Definition: angle.h:78
Angle operator*=(Scalar s)
Multiplies angle by scalar.
Definition: angle.h:152
bool operator==(Angle< T > lhs, Angle< T > rhs)
Tests two Angle objects for equality.
Definition: angle.h:255
apollo::cyber::base::std value
Angle operator+=(Angle other)
Sums another angle to the current one.
Definition: angle.h:131
Angle(const T value=0)
Constructs an Angle object from raw internal value.
Definition: angle.h:87
static constexpr T RAW_PI_2
Internal representation of pi/2.
Definition: angle.h:93