RaidZeroLib
Coroutine robot framework for VEX V5
Loading...
Searching...
No Matches
Utility

Math helpers. More...

Functions

template<typename T>
constexpr int rz::sgn (T val) noexcept
 Sign of a value: 1 if positive, -1 if negative, 0 if zero.
double rz::constrainAngle360 (double angle) noexcept
 Wraps an angle in degrees to [0, 360).
double rz::constrainAngle180 (double angle) noexcept
 Wraps an angle in degrees to [-180, 180).
Angle rz::constrainAngle360 (Angle angle) noexcept
 Wraps an angle to [0, 2π).
Angle rz::constrainAngle180 (Angle angle) noexcept
 Wraps an angle to [-π, π).
double rz::sinc (double x) noexcept
 sin(x) / x, numerically stable near zero.
std::optional< std::pair< double, double > > rz::quadraticFormula (double a, double b, double c) noexcept
 Real roots of ax² + bx + c = 0, smallest first.

Detailed Description

Math helpers.

Function Documentation

◆ constrainAngle180() [1/2]

Angle rz::constrainAngle180 ( Angle angle)
nodiscardnoexcept

Wraps an angle to [-π, π).

◆ constrainAngle180() [2/2]

double rz::constrainAngle180 ( double angle)
nodiscardnoexcept

Wraps an angle in degrees to [-180, 180).

◆ constrainAngle360() [1/2]

Angle rz::constrainAngle360 ( Angle angle)
nodiscardnoexcept

Wraps an angle to [0, 2π).

◆ constrainAngle360() [2/2]

double rz::constrainAngle360 ( double angle)
nodiscardnoexcept

Wraps an angle in degrees to [0, 360).

◆ quadraticFormula()

std::optional< std::pair< double, double > > rz::quadraticFormula ( double a,
double b,
double c )
nodiscardnoexcept

Real roots of ax² + bx + c = 0, smallest first.

Returns
Both roots (equal if the discriminant is zero), or nullopt if there are no real roots.

◆ sgn()

template<typename T>
int rz::sgn ( T val)
nodiscardconstexprnoexcept

Sign of a value: 1 if positive, -1 if negative, 0 if zero.

Works for arithmetic types and au quantities.

◆ sinc()

double rz::sinc ( double x)
nodiscardnoexcept

sin(x) / x, numerically stable near zero.