4namespace tinyrobotics {
7
8
9
10
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
45 Angle(
float angle,
AngleUnit unit) { setValue(angle, unit); }
47 void setValue(
float newAngle,
AngleUnit newUnit) {
53 float getValue(
AngleUnit desiredUnit)
const {
54 if (unit == desiredUnit)
return angle;
57 if (desiredUnit ==
AngleUnit::RAD)
return angle * (
float)M_PI / 180.0f;
60 if (desiredUnit ==
AngleUnit::DEG)
return angle * 180.0f / (
float)M_PI;
66 Angle operator*(
float scalar)
const {
return Angle(angle * scalar, unit); }
68 Angle operator/(
float scalar)
const {
69 if (scalar == 0)
return Angle(0, unit);
70 return Angle(angle / scalar, unit);
73 bool operator==(
const Angle& other)
const {
74 return angle == other.getValue(unit);
77 bool operator!=(
const Angle& other)
const {
return !(*
this == other); }
79 bool operator<(
const Angle& other)
const {
80 return angle < other.getValue(unit);
83 bool operator<=(
const Angle& other)
const {
84 return angle <= other.getValue(unit);
87 bool operator>(
const Angle& other)
const {
88 return angle > other.getValue(unit);
91 bool operator>=(
const Angle& other)
const {
92 return angle >= other.getValue(unit);
95 Angle& operator*=(
float scalar) {
101 Angle& operator/=(
float scalar) {
115 inline void normalize() {
118 angle = normalizeAngleDeg(angle);
121 angle = normalizeAngleRad(angle);
126 void add(
Angle other) {
127 float otherAngle = other.getValue(unit);
132 void subtract(
Angle other) {
133 float otherAngle = other.getValue(unit);
Represents an angle with unit conversion and wrap-around support.
Definition: Angle.h:42
AngleUnit
Supported angle units for conversion and representation.
Definition: Angle.h:11