FRC Paradigm Shift #1259
Documentation for the 2021 Robot
Util Class Reference

Static Public Member Functions

static double DegreesToRadians (double theta)
 Convert any angle theta in degrees to radians. More...
 
static double RadiansToDegrees (double theta)
 Convert any angle theta in radians to degrees. More...
 
static double ZeroTo2PiRads (double theta)
 
static double ZeroTo360Degs (double theta)
 
static double NegPiToPiRads (double theta)
 
static double GetAverage (vector< double > numbers)
 
static double Deadzone (double inputValue, double deadzone)
 If an inputValue is smaller than its deadzone, returns 0, otherwise returns the inputValue. More...
 

Detailed Description

Definition at line 9 of file Util.h.

Member Function Documentation

double Util::DegreesToRadians ( double  theta)
static

Convert any angle theta in degrees to radians.

Definition at line 4 of file Util.cpp.

5 {
6  return theta * (2 * wpi::math::pi) / 360.0;
7 }
double Util::RadiansToDegrees ( double  theta)
static

Convert any angle theta in radians to degrees.

Definition at line 9 of file Util.cpp.

10 {
11  return theta * 360.0 / (2 * wpi::math::pi);
12 }
double Util::ZeroTo2PiRads ( double  theta)
static

Convert any angle theta in radians to its equivalent on the interval [0, 2pi]

Parameters
thetaany angle in radians
Returns
any angle within the interval [0, 2pi]

Definition at line 15 of file Util.cpp.

16 {
17  theta = fmod(theta, 2 * wpi::math::pi);
18  if (theta < 0)
19  theta += 2 * wpi::math::pi;
20 
21  return theta;
22 }
double Util::ZeroTo360Degs ( double  theta)
static

Convert any angle theta in degrees to its equivalent on the interval [0, 360]

Parameters
thetaany angle in degrees
Returns
any angle within the interval [0, 360]

Definition at line 25 of file Util.cpp.

26 {
27  theta = fmod(theta, 360.0);
28  if (theta < 0)
29  theta += 360.0;
30 
31  return theta;
32 }
double Util::NegPiToPiRads ( double  theta)
static

Convert any angle theta in radians to its equivalent on the interval [-pi, pi]

Parameters
thetaany angle in radians
Returns
any angle within the interval [-pi, pi]

Definition at line 35 of file Util.cpp.

References ZeroTo2PiRads().

36 {
37  theta = ZeroTo2PiRads(theta);
38  if (theta > wpi::math::pi)
39  theta -= 2 * wpi::math::pi;
40  else if (theta < -1.0 * wpi::math::pi)
41  theta += 2 * wpi::math::pi;
42 
43  return theta;
44 }
static double ZeroTo2PiRads(double theta)
Definition: Util.cpp:15
double Util::GetAverage ( vector< double >  numbers)
static

Get the average of a double vector

Parameters
numbersvector of doubles
Returns
average of doubles in vector

Definition at line 46 of file Util.cpp.

47 {
48  double sum = 0.0;
49 
50  for (auto n : numbers)
51  sum += n;
52 
53  return sum / numbers.size();
54 }
static double Util::Deadzone ( double  inputValue,
double  deadzone 
)
inlinestatic

If an inputValue is smaller than its deadzone, returns 0, otherwise returns the inputValue.

Definition at line 39 of file Util.h.

40  {
41  // If the input is small return 0
42  return abs(inputValue) <= deadzone ? 0 : inputValue;
43  }

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