Thunderbots Project
Loading...
Searching...
No Matches
Angle Class Referencefinal

#include <angle.h>

Public Member Functions

constexpr Angle ()
 
constexpr double toRadians () const
 
constexpr double toDegrees () const
 
constexpr Angle mod (Angle divisor) const
 
constexpr Angle remainder (const Angle &divisor) const
 
constexpr Angle abs () const
 
bool isFinite () const
 
double sin () const
 
double cos () const
 
double tan () const
 
constexpr Angle clamp () const
 
constexpr Angle minDiff (const Angle &other) const
 

Static Public Member Functions

static constexpr Angle zero ()
 
static constexpr Angle quarter ()
 
static constexpr Angle half ()
 
static constexpr Angle threeQuarter ()
 
static constexpr Angle full ()
 
static constexpr Angle fromRadians (double rad)
 
static constexpr Angle fromDegrees (double deg)
 
static Angle asin (double x)
 
static Angle acos (double x)
 
static Angle atan (double x)
 

Detailed Description

A typesafe representation of an angle.

This class helps prevent accidentally combining values in degrees and radians without proper conversion.

Constructor & Destructor Documentation

◆ Angle()

constexpr Angle ( )
inlineexplicitconstexpr

Constructs the "zero" angle.

Member Function Documentation

◆ abs()

constexpr Angle abs ( ) const
inlineconstexpr

Returns the absolute value of this angle.

Returns
the absolute value of this angle.

◆ acos()

Angle acos ( double  x)
inlinestatic

Computes the arccosine of a value.

Parameters
xthe value.
Returns
the angle.

◆ asin()

Angle asin ( double  x)
inlinestatic

Computes the arcsine of a value.

Parameters
xthe value.
Returns
the angle.

◆ atan()

Angle atan ( double  x)
inlinestatic

Computes the arctangent of a value.

Parameters
xthe value.
Returns
the angle.

◆ clamp()

constexpr Angle clamp ( ) const
inlineconstexpr

Limits this angle to [−π, π].

The angle is rotated by a multiple of 2π until it lies within the target interval.

Returns
the clamped angle.

◆ cos()

double cos ( ) const
inline

Computes the cosine of this angle.

Returns
the cosine of this angle.

◆ fromDegrees()

constexpr Angle fromDegrees ( double  deg)
inlinestaticconstexpr

Constructs an angle from a value in degrees.

Parameters
degthe angle in degrees
Returns
the constructed angle

◆ fromRadians()

constexpr Angle fromRadians ( double  rad)
inlinestaticconstexpr

Constructs an angle from a value in radians.

Parameters
radthe angle in radians.
Returns
the constructed angle

◆ full()

constexpr Angle full ( )
inlinestaticconstexpr

The full-turn angle (360°).

◆ half()

constexpr Angle half ( )
inlinestaticconstexpr

The half-turn angle (180°).

◆ isFinite()

bool isFinite ( ) const
inline

Checks whether the angle is finite.

Returns
true if the angle is finite, and false if it is ±∞ or NaN.

◆ minDiff()

constexpr Angle minDiff ( const Angle other) const
inlineconstexpr

Returns the smallest possible rotational difference between this angle and another angle.

Parameters
otherthe second angle.
Returns
the angle between this Angle and other, in the range [0, π].

◆ mod()

constexpr Angle mod ( Angle  divisor) const
inlineconstexpr

Computes the modulus of a division between this angle and another angle.

Parameters
divisorthe divisor.
Returns
the modulus of this Angle ÷ divisor.

◆ quarter()

constexpr Angle quarter ( )
inlinestaticconstexpr

The quarter-turn angle (90°).

◆ remainder()

constexpr Angle remainder ( const Angle divisor) const
inlineconstexpr

Computes the remainder of a division between this angle and another angle.

Parameters
divisorthe divisor.
Returns
the remainder of this Angle ÷ divisor.

◆ sin()

double sin ( ) const
inline

Computes the sine of this angle.

Returns
the sine of this angle.

◆ tan()

double tan ( ) const
inline

Computes the tangent of this angle.

Returns
the tangent of this angle.

◆ threeQuarter()

constexpr Angle threeQuarter ( )
inlinestaticconstexpr

The three-quarter turn angle (270°).

◆ toDegrees()

constexpr double toDegrees ( ) const
inlineconstexpr

Converts this angle to a value in degrees.

Returns
the number of degrees in this angle in the range [0,360)

◆ toRadians()

constexpr double toRadians ( ) const
inlineconstexpr

Converts this angle to a value in radians.

Returns
the number of radians in this angle in the range [0, 2PI)

◆ zero()

constexpr Angle zero ( )
inlinestaticconstexpr

The zero angle.


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