TinyRobotics
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Angle Class Reference

Represents an angle with unit conversion and wrap-around support. More...

#include <Angle.h>

Public Member Functions

 Angle (float angle, AngleUnit unit)
 
void setValue (float newAngle, AngleUnit newUnit)
 
float getValue (AngleUnit desiredUnit) const
 
Angle operator* (float scalar) const
 
Angle operator/ (float scalar) const
 
bool operator== (const Angle &other) const
 
bool operator!= (const Angle &other) const
 
bool operator< (const Angle &other) const
 
bool operator<= (const Angle &other) const
 
bool operator> (const Angle &other) const
 
bool operator>= (const Angle &other) const
 
Angleoperator*= (float scalar)
 
Angleoperator/= (float scalar)
 

Protected Member Functions

void normalize ()
 
void add (Angle other)
 
void subtract (Angle other)
 

Protected Attributes

float angle = 0.0f
 
AngleUnit unit = AngleUnit::DEG
 

Detailed Description

Represents an angle with unit conversion and wrap-around support.

The Angle class encapsulates an angle value and its unit, supporting degrees (DEG) and radians (RAD). It provides methods to set and retrieve the angle in any supported unit, automatically handling conversions and wrap-around (0-360° or 0-2π rad).

Example:

Angle a(90.0, AngleUnit::DEG);
float rad = a.getValue(AngleUnit::RAD); // Convert to radians
a.add(Angle(45.0, AngleUnit::DEG)); // Add 45 degrees
Angle b = a - Angle(180.0, AngleUnit::DEG); // Subtract 180 degrees
Represents an angle with unit conversion and wrap-around support.
Definition: Angle.h:42
Note
Invalid conversions return -1.0f.
See also
AngleUnit

The documentation for this class was generated from the following file: