Mathematical Utility Functions

Functions

FARSA_UTIL_TEMPLATE float invLinearMap (float x, float min=-10, float max=10, float outMin=-1, float outMax=1)
 Inversed Linear mapping from [min,max] to [outMin, outMax]. More...
 
FARSA_UTIL_TEMPLATE float linearMap (float x, float min=-10, float max=10, float outMin=-1, float outMax=1)
 Linear mapping from [min,max] to [outMin, outMax]. More...
 
template<class T , class U >
FARSA_UTIL_TEMPLATE const T max (const T &t1, const U &t2)
 Template for max calculation. More...
 
template<class T , class U >
FARSA_UTIL_TEMPLATE const T min (const T &t1, const U &t2)
 Template for min calculation. More...
 
FARSA_UTIL_TEMPLATE real normalizeDegree (real x)
 Restricts the angle between -180° and 180° More...
 
FARSA_UTIL_TEMPLATE real normalizeDegree0360 (real x)
 Restricts the angle between 0.0° and 360° More...
 
FARSA_UTIL_TEMPLATE real normalizeRad (real x)
 Restricts the angle between -PI_GRECO and PI_GRECO. More...
 
FARSA_UTIL_TEMPLATE real normalizeRad02pi (real x)
 Restricts the angle between 0.0 and 2.0 * PI_GRECO. More...
 
FARSA_UTIL_TEMPLATE real ramp (real minv, real maxv, real value)
 Clamps the value of a variable in the given range. More...
 
FARSA_UTIL_TEMPLATE real toDegree (real x)
 Converts radians to degrees. More...
 
FARSA_UTIL_TEMPLATE real toRad (real x)
 Converts degrees to radians. More...
 

Detailed Description

Function Documentation

FARSA_UTIL_TEMPLATE float farsa::invLinearMap ( float  x,
float  min = -10,
float  max = 10,
float  outMin = -1,
float  outMax = 1 
)
inline

Inversed Linear mapping from [min,max] to [outMin, outMax].

 --------\             outMax
          \
           --------   outMin
      min   max
 
Parameters
xthe value to map
minthe minumum allowed value of x
maxthe maximum allowed value of x
outMinthe minimum value of the mapped value
outMaxthe maximum value of the mapped value
Returns
the mapped value

Definition at line 232 of file mathutils.h.

References farsa::max(), and farsa::min().

FARSA_UTIL_TEMPLATE float farsa::linearMap ( float  x,
float  min = -10,
float  max = 10,
float  outMin = -1,
float  outMax = 1 
)
inline

Linear mapping from [min,max] to [outMin, outMax].

           /--------  outMax
          /
 --------/            outMin
      min   max
Parameters
xthe value to map
minthe minumum allowed value of x
maxthe maximum allowed value of x
outMinthe minimum value of the mapped value
outMaxthe maximum value of the mapped value
Returns
the mapped value

Definition at line 201 of file mathutils.h.

References farsa::max(), and farsa::min().

FARSA_UTIL_TEMPLATE const T farsa::max ( const T &  t1,
const U &  t2 
)

Template for max calculation.

Parameters
t1the first element to compare
t2the second element to compare
Returns
the maxumum between t1 and t2

Definition at line 154 of file mathutils.h.

Referenced by farsa::invLinearMap(), farsa::linearMap(), Intervals::unite(), and DataStreamPlot::updatePlot().

FARSA_UTIL_TEMPLATE const T farsa::min ( const T &  t1,
const U &  t2 
)

Template for min calculation.

Parameters
t1the first element to compare
t2the second element to compare
Returns
the minumum between t1 and t2

Definition at line 136 of file mathutils.h.

Referenced by farsa::invLinearMap(), farsa::linearMap(), Intervals::unite(), and DataStreamPlot::updatePlot().

FARSA_UTIL_TEMPLATE real farsa::normalizeDegree ( real  x)
inline

Restricts the angle between -180° and 180°

Parameters
xthe angle to restrict
Returns
the angle restricted between -180° and 180°

Definition at line 121 of file mathutils.h.

References farsa::normalizeDegree0360().

FARSA_UTIL_TEMPLATE real farsa::normalizeDegree0360 ( real  x)
inline

Restricts the angle between 0.0° and 360°

Parameters
xthe angle to restrict
Returns
the angle restricted between 0.0° and 360°

Definition at line 109 of file mathutils.h.

Referenced by farsa::normalizeDegree().

FARSA_UTIL_TEMPLATE real farsa::normalizeRad ( real  x)
inline

Restricts the angle between -PI_GRECO and PI_GRECO.

Parameters
xthe angle to restrict
Returns
the angle restricted between -PI_GRECO and PI_GRECO

Definition at line 84 of file mathutils.h.

References farsa::normalizeRad02pi().

FARSA_UTIL_TEMPLATE real farsa::normalizeRad02pi ( real  x)
inline

Restricts the angle between 0.0 and 2.0 * PI_GRECO.

Parameters
xthe angle to restrict
Returns
the angle restricted between 0.0 and 2.0 * PI_GRECO

Definition at line 72 of file mathutils.h.

Referenced by farsa::normalizeRad().

FARSA_UTIL_TEMPLATE real farsa::ramp ( real  minv,
real  maxv,
real  value 
)
inline

Clamps the value of a variable in the given range.

Parameters
minvthe minimum value of the range
maxvthe maximum value of the range
valuethe value to constraint
Returns
if value is greater than maxv, returns the maxv, if value is less than minv, returns minv, otherwise returns value

Definition at line 173 of file mathutils.h.

FARSA_UTIL_TEMPLATE real farsa::toDegree ( real  x)
inline

Converts radians to degrees.

Parameters
xthe angle in radians
Returns
the angle in degrees

Definition at line 97 of file mathutils.h.

FARSA_UTIL_TEMPLATE real farsa::toRad ( real  x)
inline

Converts degrees to radians.

Parameters
xthe ange in degrees
Returns
the angle in radians

Definition at line 60 of file mathutils.h.