ThunderLib
Loading...
Searching...
No Matches
thunder::types::CanonicalAngle Class Reference

#include <CanonicalAngle.hpp>

Public Member Functions

 CanonicalAngle ()=default
 
 CanonicalAngle (const frc::Rotation2d &rotation)
 
 CanonicalAngle (units::angle_unit auto value)
 
 CanonicalAngle (double x, double y)
 
double cos () const
 
double sin () const
 
double tan () const
 
units::radian_t radians () const
 
units::degree_t degrees () const
 
 operator frc::Rotation2d () const
 
 operator units::angle_unit auto () const
 
bool operator== (const CanonicalAngle &other) const
 
bool operator!= (const CanonicalAngle &other) const
 
CanonicalAngle operator- () const
 
CanonicalAngle operator+ (const CanonicalAngle &other) const
 
CanonicalAngle operator- (const CanonicalAngle &other) const
 
CanonicalAngle operator* (double scalar) const
 
CanonicalAngle operator/ (double scalar) const
 
CanonicalAngle rotateBy (const CanonicalAngle &other) const
 
CanonicalAngle supplementary () const
 
bool isSupplementaryTo (const CanonicalAngle &other) const
 

Detailed Description

Represents an angle in the range of (-π, π]. This class is similar to frc::Rotation2d, but is designed to represent angles in a more mathematically consistent way, avoiding issues with wrapping and discontinuities.

Constructor & Destructor Documentation

◆ CanonicalAngle() [1/4]

thunder::types::CanonicalAngle::CanonicalAngle ( )
default

Constructs a CanonicalAngle with a default value of 0 radians.

◆ CanonicalAngle() [2/4]

thunder::types::CanonicalAngle::CanonicalAngle ( const frc::Rotation2d & rotation)
inline

Constructs a CanonicalAngle from a Rotation2d.

Parameters
rotationThe Rotation2d to convert to a CanonicalAngle.

◆ CanonicalAngle() [3/4]

thunder::types::CanonicalAngle::CanonicalAngle ( units::angle_unit auto value)
inline

Constructs a CanonicalAngle with the specified angle value.

Parameters
valueThe angle value.

◆ CanonicalAngle() [4/4]

thunder::types::CanonicalAngle::CanonicalAngle ( double x,
double y )
inline

Constructs a CanonicalAngle with the specified x and y components.

Parameters
xThe x component or cosine of the angle.
yThe y component or sine of the angle.

Member Function Documentation

◆ isSupplementaryTo()

bool thunder::types::CanonicalAngle::isSupplementaryTo ( const CanonicalAngle & other) const
inline

Checks if this angle is supplementary to another angle.

Parameters
otherThe angle to check against.
Returns
True if the angles are supplementary, false otherwise.

◆ operator-()

CanonicalAngle thunder::types::CanonicalAngle::operator- ( ) const
inline

Takes the inverse (negation) of the current angle.

Returns
The inverse of the current angle.

◆ rotateBy()

CanonicalAngle thunder::types::CanonicalAngle::rotateBy ( const CanonicalAngle & other) const
inline

Rotates the current angle by another angle.

Parameters
otherThe angle to rotate by.
Returns
The rotated angle.

◆ supplementary()

CanonicalAngle thunder::types::CanonicalAngle::supplementary ( ) const
inline

Calculates the supplementary angle.

Returns
The supplementary angle.

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