Apollo
6.0
Open source self driving car software
|
The Angle class uses an integer to represent an angle, and supports commonly-used operations such as addition and subtraction, as well as the use of trigonometric functions. More...
#include <angle.h>
Public Member Functions | |
Angle (const T value=0) | |
Constructs an Angle object from raw internal value. More... | |
T | raw () const |
Getter of value_. More... | |
double | to_deg () const |
Converts the internal representation to degrees. More... | |
double | to_rad () const |
Converts the internal representation to radians. More... | |
Angle | operator+= (Angle other) |
Sums another angle to the current one. More... | |
Angle | operator-= (Angle other) |
Subtracts another angle from the current one. More... | |
template<typename Scalar > | |
Angle | operator*= (Scalar s) |
Multiplies angle by scalar. More... | |
template<typename Scalar > | |
Angle | operator/= (Scalar s) |
Divides angle by scalar. More... | |
Static Public Member Functions | |
static Angle | from_deg (const double value) |
Constructs an Angle object from an angle in degrees (factory). More... | |
static Angle | from_rad (const double value) |
Constructs an Angle object from an angle in radians (factory). More... | |
Static Public Attributes | |
static constexpr T | RAW_PI = std::numeric_limits<T>::min() |
Internal representation of pi. More... | |
static constexpr T | RAW_PI_2 |
Internal representation of pi/2. More... | |
static constexpr double | DEG_TO_RAW = RAW_PI / -180.0 |
Used for converting angle units. More... | |
static constexpr double | RAD_TO_RAW = RAW_PI * -M_1_PI |
Used for converting angle units. More... | |
static constexpr double | RAW_TO_DEG = -180.0 / RAW_PI |
Used for converting angle units. More... | |
static constexpr double | RAW_TO_RAD = -M_PI / RAW_PI |
Used for converting angle units. More... | |
The Angle class uses an integer to represent an angle, and supports commonly-used operations such as addition and subtraction, as well as the use of trigonometric functions.
Having a specialized Angle class prevents code repetition, namely for tasks such as computing angle differences or finding equivalent angles in some specified interval, typically [-pi, pi). Representing angles by integers has the following advantages: 1) Finer level of precision control (< means "less precise than"): Angle8 < Angle16 < float < Angle32 < double < Angle64. 2) Angle8 and Angle16 allow super fast trigonometric functions via a 64-KiB lookup table. 3) Higher precision with the same representation size. The use of the Angle class is encouraged. In particular, Angle32 should be used for latitude/longitude (<1cm error). Angle16 is precise enough for localization/object detection.
T | signed integer type |
|
inlineexplicit |
|
inlinestatic |
|
inlinestatic |
|
inline |
Multiplies angle by scalar.
s | A scalar |
|
inline |
|
inline |
Subtracts another angle from the current one.
other | Another Angle object |
|
inline |
Divides angle by scalar.
s | A scalar |
|
inline |
Getter of value_.
|
inline |
Converts the internal representation to degrees.
|
inline |
Converts the internal representation to radians.
|
static |
Used for converting angle units.
|
static |
Used for converting angle units.
|
static |
Internal representation of pi.
|
static |
Internal representation of pi/2.
|
static |
Used for converting angle units.
|
static |
Used for converting angle units.