RSC  0.16.0
rsc::math::MathUtils Class Reference

General math-related utility functions. More...

#include <MathUtils.h>

Collaboration diagram for rsc::math::MathUtils:
Collaboration graph

Static Public Member Functions

static double getDefaultAnglePrecision ()
 Default precision used for operations with angles in rad. More...
 
static double normalizeAngle (const double &angleInRad)
 Normalizes the given angle in rad to interval $[0,2\pi[$. More...
 
static bool isSameAngle (const double &firstInRad, const double &secondInRad, const double &precision=getDefaultAnglePrecision())
 Tests if two given angles in rad are the same angle regarding things like $0 = n\cdot2\cdot\pi$ etc. More...
 
static double radianFromDegree (const double &degree)
 Converts an angle given in degrees to radian. More...
 
static double degreeFromRadian (const double &radian)
 Converts an angle given in radian to degrees. More...
 
static double getDefaultClosePrecision ()
 Returns the default precision used for isClose. More...
 
static bool isClose (const double &a, const double &b, const double &precision=getDefaultClosePrecision())
 Checks two floating point numbers for equality using a specified tolerance. More...
 

Static Private Member Functions

static double getTwoPi ()
 

Detailed Description

General math-related utility functions.

Author
jwienke

Definition at line 39 of file MathUtils.h.

Member Function Documentation

double rsc::math::MathUtils::degreeFromRadian ( const double &  radian)
static

Converts an angle given in radian to degrees.

Parameters
radianangle in rad
Returns
angle in degree

Definition at line 68 of file MathUtils.cpp.

double rsc::math::MathUtils::getDefaultAnglePrecision ( )
static

Default precision used for operations with angles in rad.

Definition at line 40 of file MathUtils.cpp.

double rsc::math::MathUtils::getDefaultClosePrecision ( )
static

Returns the default precision used for isClose.

Returns
default precision

Definition at line 72 of file MathUtils.cpp.

double rsc::math::MathUtils::getTwoPi ( )
staticprivate

Definition at line 36 of file MathUtils.cpp.

bool rsc::math::MathUtils::isClose ( const double &  a,
const double &  b,
const double &  precision = getDefaultClosePrecision() 
)
static

Checks two floating point numbers for equality using a specified tolerance.

Parameters
afirst number to compare
bsecond number to compare
precisionprecision to use for the comparison, default is getDefaultClosePrecision
Returns
true if $|a-b| < \textrm{precision}$

Definition at line 76 of file MathUtils.cpp.

bool rsc::math::MathUtils::isSameAngle ( const double &  firstInRad,
const double &  secondInRad,
const double &  precision = getDefaultAnglePrecision() 
)
static

Tests if two given angles in rad are the same angle regarding things like $0 = n\cdot2\cdot\pi$ etc.

Parameters
firstInRadfirst angle to test in rad
secondInRadsecond angle to test in rad
precisionprecision for the equality check in rad
Returns
true if the difference of both angles is less than precision, else false

Definition at line 56 of file MathUtils.cpp.

double rsc::math::MathUtils::normalizeAngle ( const double &  angleInRad)
static

Normalizes the given angle in rad to interval $[0,2\pi[$.

Parameters
angleInRadarbitrary angle in rad
Returns
normalization of the angle to interval $[0,2\pi[$

Definition at line 44 of file MathUtils.cpp.

double rsc::math::MathUtils::radianFromDegree ( const double &  degree)
static

Converts an angle given in degrees to radian.

Parameters
degreeangle in degree
Returns
angle in rad

Definition at line 64 of file MathUtils.cpp.


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