RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
rz::Rotation Class Reference

Immutable planar rotation about the Z axis. More...

#include <Rotation.hpp>

Public Member Functions

constexpr Rotation () noexcept=default
 Constructs a zero rotation.
 Rotation (Angle theta) noexcept
 Constructs from an angle.
 Rotation (Length x, Length y) noexcept
 Constructs from a Cartesian vector (x, y).
 Rotation (double x, double y) noexcept
 Constructs from a Cartesian vector (x, y).
Angle Theta () const noexcept
 Returns the normalized angle in radians.
double Sin () const noexcept
 Sine of the rotation.
double Cos () const noexcept
 Cosine of the rotation.
double Tan () const noexcept
 Tangent of the rotation.
Rotation operator+ (const Rotation &rhs) const noexcept
 Angle addition.
Rotation operator- (const Rotation &rhs) const noexcept
 Angle subtraction.
Rotation & operator+= (const Rotation &rhs) noexcept
 Adds rhs to this rotation, normalized.
Rotation & operator-= (const Rotation &rhs) noexcept
 Subtracts rhs from this rotation, normalized.
Rotation operator- () const noexcept
 Unary negation.
Rotation operator* (double scalar) const noexcept
 Multiplies the angle by a scalar.
Rotation operator/ (double scalar) const noexcept
 Divides the angle by a scalar.
bool isApprox (const Rotation &rhs) const noexcept
 Approximate equality check with angular tolerance.

Detailed Description

Immutable planar rotation about the Z axis.

Rotation represents an angle in radians (right-handed, counter-clockwise positive) and provides trigonometric accessors, arithmetic, and comparison helpers.

All angles are internally normalized to (-180, 180] degrees so that equivalent rotations share a canonical representation. This guarantees stable arithmetic and comparisons across operations.

Constructor & Destructor Documentation

◆ Rotation() [1/4]

rz::Rotation::Rotation ( )
constexprdefaultnoexcept

Constructs a zero rotation.

Equivalent to Rotation(au::ZERO); the internal angle is 0 rad.

◆ Rotation() [2/4]

rz::Rotation::Rotation ( Angle theta)
explicitnoexcept

Constructs from an angle.

Parameters
thetathe angle.

◆ Rotation() [3/4]

rz::Rotation::Rotation ( Length x,
Length y )
noexcept

Constructs from a Cartesian vector (x, y).

Computes atan2(y, x) to obtain the heading of the vector. If both x and y are zero, the resulting rotation is defined as zero.

Parameters
xX component (length units).
yY component (length units).

◆ Rotation() [4/4]

rz::Rotation::Rotation ( double x,
double y )
noexcept

Constructs from a Cartesian vector (x, y).

Computes atan2(y, x) to obtain the heading of the vector. If both x and y are zero, the resulting rotation is defined as zero.

Parameters
xX component (unitless).
yY component (unitless).

Member Function Documentation

◆ Cos()

double rz::Rotation::Cos ( ) const
noexcept

Cosine of the rotation.

Returns
cos(theta) as a double.

◆ isApprox()

bool rz::Rotation::isApprox ( const Rotation & rhs) const
noexcept

Approximate equality check with angular tolerance.

Computes the normalized minimum signed difference between the two rotations and compares its absolute value to 1e-9 radians.

Parameters
rhsRotation to compare with.
Returns
true if the two rotation within 1e-9 radians, otherwise false.

◆ operator*()

Rotation rz::Rotation::operator* ( double scalar) const
noexcept

Multiplies the angle by a scalar.

Parameters
scalarMultiplication applied to the angle.
Returns
New rotation with angle theta * scalar, normalized.

◆ operator+()

Rotation rz::Rotation::operator+ ( const Rotation & rhs) const
noexcept

Angle addition.

Parameters
rhsRotation to add.
Returns
New rotation equal to this->theta + rhs.theta, normalized.

◆ operator+=()

Rotation & rz::Rotation::operator+= ( const Rotation & rhs)
noexcept

Adds rhs to this rotation, normalized.

◆ operator-() [1/2]

Rotation rz::Rotation::operator- ( ) const
noexcept

Unary negation.

Returns
New rotation equal to -theta, normalized.

◆ operator-() [2/2]

Rotation rz::Rotation::operator- ( const Rotation & rhs) const
noexcept

Angle subtraction.

Parameters
rhsRotation to subtract.
Returns
New rotation equal to this->theta - rhs.theta, normalized.

◆ operator-=()

Rotation & rz::Rotation::operator-= ( const Rotation & rhs)
noexcept

Subtracts rhs from this rotation, normalized.

◆ operator/()

Rotation rz::Rotation::operator/ ( double scalar) const
noexcept

Divides the angle by a scalar.

Equivalent to multiplying by 1.0 / scalar.

Parameters
scalarDivisor applied to the angle.
Returns
New rotation with angle theta / scalar, normalized.

◆ Sin()

double rz::Rotation::Sin ( ) const
noexcept

Sine of the rotation.

Returns
sin(theta) as a double.

◆ Tan()

double rz::Rotation::Tan ( ) const
noexcept

Tangent of the rotation.

Returns
tan(theta) as a double.

◆ Theta()

Angle rz::Rotation::Theta ( ) const
noexcept

Returns the normalized angle in radians.

Returns
Angle in radians.

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