WPILibC++  2020.3.2-60-g3011ebe
frc::Rotation2d Class Reference

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

#include <Rotation2d.h>

## Public Member Functions

constexpr Rotation2d ()=default
Constructs a Rotation2d with a default angle of 0 degrees.

Constructs a Rotation2d with the given radian value. More...

Rotation2d (double x, double y)
Constructs a Rotation2d with the given x and y (cosine and sine) components. More...

Rotation2d operator+ (const Rotation2d &other) const
Adds two rotations together, with the result being bounded between -pi and pi. More...

Rotation2doperator+= (const Rotation2d &other)
Adds a rotation to the current rotation. More...

Rotation2d operator- (const Rotation2d &other) const
Subtracts the new rotation from the current rotation and returns the new rotation. More...

Rotation2doperator-= (const Rotation2d &other)
Subtracts the new rotation from the current rotation. More...

Rotation2d operator- () const
Takes the inverse of the current rotation. More...

Rotation2d operator* (double scalar) const
Multiplies the current rotation by a scalar. More...

bool operator== (const Rotation2d &other) const
Checks equality between this Rotation2d and another object. More...

bool operator!= (const Rotation2d &other) const
Checks inequality between this Rotation2d and another object. More...

Rotation2d RotateBy (const Rotation2d &other) const
Adds the new rotation to the current rotation using a rotation matrix. More...

Returns the radian value of the rotation. More...

units::degree_t Degrees () const
Returns the degree value of the rotation. More...

double Cos () const
Returns the cosine of the rotation. More...

double Sin () const
Returns the sine of the rotation. More...

double Tan () const
Returns the tangent of the rotation. More...

## Detailed Description

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

## ◆ Rotation2d() [1/2]

 frc::Rotation2d::Rotation2d ( units::radian_t value )

Constructs a Rotation2d with the given radian value.

Parameters
 value The value of the angle in radians.

## ◆ Rotation2d() [2/2]

 frc::Rotation2d::Rotation2d ( double x, double y )

Constructs a Rotation2d with the given x and y (cosine and sine) components.

The x and y don't have to be normalized.

Parameters
 x The x component or cosine of the rotation. y The y component or sine of the rotation.

## ◆ Cos()

 double frc::Rotation2d::Cos ( ) const
inline

Returns the cosine of the rotation.

Returns
The cosine of the rotation.

## ◆ Degrees()

 units::degree_t frc::Rotation2d::Degrees ( ) const
inline

Returns the degree value of the rotation.

Returns
The degree value of the rotation.

## ◆ operator!=()

 bool frc::Rotation2d::operator!= ( const Rotation2d & other ) const

Checks inequality between this Rotation2d and another object.

Parameters
 other The other object.
Returns
Whether the two objects are not equal.

## ◆ operator*()

 Rotation2d frc::Rotation2d::operator* ( double scalar ) const

Multiplies the current rotation by a scalar.

Parameters
 scalar The scalar.
Returns
The new scaled Rotation2d.

## ◆ operator+()

 Rotation2d frc::Rotation2d::operator+ ( const Rotation2d & other ) const

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

For example, Rotation2d.FromDegrees(30) + Rotation2d.FromDegrees(60) = Rotation2d{-pi/2}

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

## ◆ operator+=()

 Rotation2d& frc::Rotation2d::operator+= ( const Rotation2d & other )

Adds a rotation to the current rotation.

This is similar to the + operator except that it mutates the current object.

Parameters
 other The rotation to add.
Returns
The reference to the new mutated object.

## ◆ operator-() [1/2]

 Rotation2d frc::Rotation2d::operator- ( ) const

Takes the inverse of the current rotation.

This is simply the negative of the current angular value.

Returns
The inverse of the current rotation.

## ◆ operator-() [2/2]

 Rotation2d frc::Rotation2d::operator- ( const Rotation2d & other ) const

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

For example, Rotation2d.FromDegrees(10) - Rotation2d.FromDegrees(100) = Rotation2d{-pi/2}

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

## ◆ operator-=()

 Rotation2d& frc::Rotation2d::operator-= ( const Rotation2d & other )

Subtracts the new rotation from the current rotation.

This is similar to the - operator except that it mutates the current object.

Parameters
 other The rotation to subtract.
Returns
The reference to the new mutated object.

## ◆ operator==()

 bool frc::Rotation2d::operator== ( const Rotation2d & other ) const

Checks equality between this Rotation2d and another object.

Parameters
 other The other object.
Returns
Whether the two objects are equal.

inline

Returns the radian value of the rotation.

Returns
The radian value of the rotation.

## ◆ RotateBy()

 Rotation2d frc::Rotation2d::RotateBy ( const Rotation2d & other ) const

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

[cos_new] [other.cos, -other.sin][cos] [sin_new] = [other.sin, other.cos][sin]

value_new = std::atan2(cos_new, sin_new)

Parameters
 other The rotation to rotate by.
Returns
The new rotated Rotation2d.

## ◆ Sin()

 double frc::Rotation2d::Sin ( ) const
inline

Returns the sine of the rotation.

Returns
The sine of the rotation.

## ◆ Tan()

 double frc::Rotation2d::Tan ( ) const
inline

Returns the tangent of the rotation.

Returns
The tangent of the rotation.

The documentation for this class was generated from the following file:
• /__w/1/s/wpilibc/src/main/native/include/frc/geometry/Rotation2d.h