TrajoptLib
Library for generating time-optimal trajectories for FRC robots.
Loading...
Searching...
No Matches
trajopt::Rotation2< T > Class Template Reference

#include <trajopt/geometry/rotation2.hpp>

Public Member Functions

constexpr Rotation2 ()=default
 Constructs a rotation with a default angle of 0 degrees.
constexpr Rotation2 (const T &angle)
constexpr Rotation2 (T cos, T sin)
constexpr Rotation2 (double x, double y)
template<typename U>
constexpr Rotation2 (const Rotation2< U > &other)
constexpr Rotation2< T > operator+ (const Rotation2< T > &other) const
constexpr Rotation2< T > operator- (const Rotation2< T > &other) const
constexpr Rotation2< T > operator- () const
template<typename U>
constexpr Rotation2< U > rotate_by (const Rotation2< U > &other) const
constexpr T radians () const
constexpr T degrees () const
constexpr const T & cos () const
constexpr const T & sin () const

Detailed Description

template<typename T>
class trajopt::Rotation2< T >

A rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).

Constructor & Destructor Documentation

◆ Rotation2() [1/4]

template<typename T>
trajopt::Rotation2< T >::Rotation2 ( const T & angle)
inlineconstexpr

Constructs a rotation with the given angle.

Parameters
angleThe angle in radians.

◆ Rotation2() [2/4]

template<typename T>
trajopt::Rotation2< T >::Rotation2 ( T cos,
T sin )
inlineconstexpr

Constructs a rotation with the given cosine and sine components.

Parameters
cosThe cosine component of the rotation.
sinThe sine component of the rotation.

◆ Rotation2() [3/4]

template<typename T>
trajopt::Rotation2< T >::Rotation2 ( double x,
double y )
inlineconstexpr

Constructs a rotation with the given x and y components. The x and y don't have to be normalized.

Parameters
xThe x component of the rotation.
yThe y component of the rotation.

◆ Rotation2() [4/4]

template<typename T>
template<typename U>
trajopt::Rotation2< T >::Rotation2 ( const Rotation2< U > & other)
inlineexplicitconstexpr

Coerces one rotation type into another.

Parameters
otherThe other rotation type.

Member Function Documentation

◆ cos()

template<typename T>
const T & trajopt::Rotation2< T >::cos ( ) const
inlineconstexpr

Returns the cosine of the rotation.

Returns
The cosine of the rotation.

◆ degrees()

template<typename T>
T trajopt::Rotation2< T >::degrees ( ) const
inlineconstexpr

Returns the rotation as an Euler angle in degrees.

Returns
The Euler angle in degrees.

◆ operator+()

template<typename T>
Rotation2< T > trajopt::Rotation2< T >::operator+ ( const Rotation2< T > & other) const
inlineconstexpr

Adds two rotations together, with the result being bounded between -pi and pi.

Parameters
otherThe rotation to add.
Returns
The sum of the two rotations.

◆ operator-() [1/2]

template<typename T>
Rotation2< T > trajopt::Rotation2< T >::operator- ( ) const
inlineconstexpr

Takes the inverse of the current rotation.

Returns
The inverse of the current rotation.

◆ operator-() [2/2]

template<typename T>
Rotation2< T > trajopt::Rotation2< T >::operator- ( const Rotation2< T > & other) const
inlineconstexpr

Subtracts the new rotation from the current rotation and returns the new rotation.

Parameters
otherThe rotation to subtract.
Returns
The difference between the two rotations.

◆ radians()

template<typename T>
T trajopt::Rotation2< T >::radians ( ) const
inlineconstexpr

Returns the rotation as an Euler angle in radians.

Returns
The Euler angle in radians.

◆ rotate_by()

template<typename T>
template<typename U>
Rotation2< U > trajopt::Rotation2< T >::rotate_by ( const Rotation2< U > & other) const
inlineconstexpr

Adds the new rotation to the current rotation using a clockwise rotation matrix.

Parameters
otherThe rotation to rotate by.
Returns
The new rotated rotation.

◆ sin()

template<typename T>
const T & trajopt::Rotation2< T >::sin ( ) const
inlineconstexpr

Returns the sine of the rotation.

Returns
The sine of the rotation.

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