Apollo 10.0
自动驾驶开放平台
apollo::common::math::Angle< T > 模板类 参考

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. 更多...

#include <angle.h>

apollo::common::math::Angle< T > 的协作图:

Public 成员函数

 Angle (const T value=0)
 Constructs an Angle object from raw internal value.
 
raw () const
 Getter of value_.
 
double to_deg () const
 Converts the internal representation to degrees.
 
double to_rad () const
 Converts the internal representation to radians.
 
Angle operator+= (Angle other)
 Sums another angle to the current one.
 
Angle operator-= (Angle other)
 Subtracts another angle from the current one.
 
template<typename Scalar >
Angle operator*= (Scalar s)
 Multiplies angle by scalar
 
template<typename Scalar >
Angle operator/= (Scalar s)
 Divides angle by scalar
 

静态 Public 成员函数

static Angle from_deg (const double value)
 Constructs an Angle object from an angle in degrees (factory).
 
static Angle from_rad (const double value)
 Constructs an Angle object from an angle in radians (factory).
 

静态 Public 属性

static constexpr T RAW_PI = std::numeric_limits<T>::min()
 Internal representation of pi
 
static constexpr T RAW_PI_2
 Internal representation of pi/2
 
static constexpr double DEG_TO_RAW = RAW_PI / -180.0
 Used for converting angle units
 
static constexpr double RAD_TO_RAW = RAW_PI * -M_1_PI
 Used for converting angle units
 
static constexpr double RAW_TO_DEG = -180.0 / RAW_PI
 Used for converting angle units
 
static constexpr double RAW_TO_RAD = -M_PI / RAW_PI
 Used for converting angle units
 

详细描述

template<typename T>
class apollo::common::math::Angle< T >

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.

参数
Tsigned integer type

在文件 angle.h58 行定义.

构造及析构函数说明

◆ Angle()

template<typename T >
apollo::common::math::Angle< T >::Angle ( const T  value = 0)
inlineexplicit

Constructs an Angle object from raw internal value.

参数
valueAngle in degrees
返回
Angle object

在文件 angle.h87 行定义.

87: value_(value) {}

成员函数说明

◆ from_deg()

template<typename T >
static Angle apollo::common::math::Angle< T >::from_deg ( const double  value)
inlinestatic

Constructs an Angle object from an angle in degrees (factory).

参数
valueAngle in degrees
返回
Angle object

在文件 angle.h69 行定义.

69 {
70 return Angle(static_cast<T>(std::lround(value * DEG_TO_RAW)));
71 }
static constexpr double DEG_TO_RAW
Used for converting angle units
Definition angle.h:97
Angle(const T value=0)
Constructs an Angle object from raw internal value.
Definition angle.h:87

◆ from_rad()

template<typename T >
static Angle apollo::common::math::Angle< T >::from_rad ( const double  value)
inlinestatic

Constructs an Angle object from an angle in radians (factory).

参数
valueAngle in radians
返回
Angle object

在文件 angle.h78 行定义.

78 {
79 return Angle(static_cast<T>(std::lround(value * RAD_TO_RAW)));
80 }
static constexpr double RAD_TO_RAW
Used for converting angle units
Definition angle.h:100

◆ operator*=()

template<typename T >
template<typename Scalar >
Angle apollo::common::math::Angle< T >::operator*= ( Scalar  s)
inline

Multiplies angle by scalar

参数
sA scalar
返回
Result of multiplication

在文件 angle.h152 行定义.

152 {
153 value_ = static_cast<T>(std::lround(value_ * s));
154 return *this;
155 }

◆ operator+=()

template<typename T >
Angle apollo::common::math::Angle< T >::operator+= ( Angle< T >  other)
inline

Sums another angle to the current one.

参数
otherAnother Angle object
返回
Result of sum

在文件 angle.h131 行定义.

131 {
132 value_ = static_cast<T>(value_ + other.value_);
133 return *this;
134 }

◆ operator-=()

template<typename T >
Angle apollo::common::math::Angle< T >::operator-= ( Angle< T >  other)
inline

Subtracts another angle from the current one.

参数
otherAnother Angle object
返回
Result of subtraction

在文件 angle.h141 行定义.

141 {
142 value_ = static_cast<T>(value_ - other.value_);
143 return *this;
144 }

◆ operator/=()

template<typename T >
template<typename Scalar >
Angle apollo::common::math::Angle< T >::operator/= ( Scalar  s)
inline

Divides angle by scalar

参数
sA scalar
返回
Result of division

在文件 angle.h163 行定义.

163 {
164 value_ = static_cast<T>(std::lround(value_ / s));
165 return *this;
166 }

◆ raw()

template<typename T >
T apollo::common::math::Angle< T >::raw ( ) const
inline

Getter of value_.

返回
Internal unsigned integer representation of angle

在文件 angle.h112 行定义.

112{ return value_; }

◆ to_deg()

template<typename T >
double apollo::common::math::Angle< T >::to_deg ( ) const
inline

Converts the internal representation to degrees.

返回
angle in degrees

在文件 angle.h118 行定义.

118{ return value_ * RAW_TO_DEG; }
static constexpr double RAW_TO_DEG
Used for converting angle units
Definition angle.h:103

◆ to_rad()

template<typename T >
double apollo::common::math::Angle< T >::to_rad ( ) const
inline

Converts the internal representation to radians.

返回
angle in radians

在文件 angle.h124 行定义.

124{ return value_ * RAW_TO_RAD; }
static constexpr double RAW_TO_RAD
Used for converting angle units
Definition angle.h:106

类成员变量说明

◆ DEG_TO_RAW

template<typename T >
constexpr double apollo::common::math::Angle< T >::DEG_TO_RAW = RAW_PI / -180.0
staticconstexpr

Used for converting angle units

在文件 angle.h97 行定义.

◆ RAD_TO_RAW

template<typename T >
constexpr double apollo::common::math::Angle< T >::RAD_TO_RAW = RAW_PI * -M_1_PI
staticconstexpr

Used for converting angle units

在文件 angle.h100 行定义.

◆ RAW_PI

template<typename T >
constexpr T apollo::common::math::Angle< T >::RAW_PI = std::numeric_limits<T>::min()
staticconstexpr

Internal representation of pi

在文件 angle.h90 行定义.

◆ RAW_PI_2

template<typename T >
constexpr T apollo::common::math::Angle< T >::RAW_PI_2
staticconstexpr
初始值:
=
static_cast<T>(-(std::numeric_limits<T>::min() >> 1))

Internal representation of pi/2

在文件 angle.h93 行定义.

◆ RAW_TO_DEG

template<typename T >
constexpr double apollo::common::math::Angle< T >::RAW_TO_DEG = -180.0 / RAW_PI
staticconstexpr

Used for converting angle units

在文件 angle.h103 行定义.

◆ RAW_TO_RAD

template<typename T >
constexpr double apollo::common::math::Angle< T >::RAW_TO_RAD = -M_PI / RAW_PI
staticconstexpr

Used for converting angle units

在文件 angle.h106 行定义.


该类的文档由以下文件生成: