Main Page | Modules | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

basicmath.hh File Reference


Detailed Description

This file defines a number of convenience macros and inline functions that are related to basic mathematical operations commonly used within RHexLib.

#include <math.h>

Defines

#define M2_PI

Functions

double saturate (const double x, const double dw_bnd, const double up_bnd)
double sign (const double x)
double fmax (double a, double b)
double fmin (double a, double b)
bool approx_equal (double x, double y, double tol)
double angle_diff (double a1, double a2, double offset)
void quaternion2euler (double(&q)[4], double(&euler)[3])


Define Documentation

#define M2_PI
 

This macro defines 2*pi for efficiency.


Function Documentation

double angle_diff double  a1,
double  a2,
double  offset
[inline]
 

This function returns the difference angle between two angles (a1

  • a2) in the range [-pi+offset,pi+offset]. As angles live on a circle topology, the difference between two angles is not uniquely determined, creating the need for such a function to select between the two possible alternatives.

bool approx_equal double  x,
double  y,
double  tol
[inline]
 

This function implements an approximate equality check with the specified tolerance. It is useful for equality comparison of floating point numbers.

double fmax double  a,
double  b
[inline]
 

This function returns the maximum of two floating point numbers

double fmin double  a,
double  b
[inline]
 

This function returns the minimum of two floating point numbers

void quaternion2euler double &  q[4],
double &  euler[3]
[inline]
 

This function converts a quaternion rotation given in "q" to euler angles returns [pitch, roll, yaw] in the vector "euler". It is based on conversion routine in HeadingServoModule by S.Skaff

double saturate const double  x,
const double  dw_bnd,
const double  up_bnd
[inline]
 

This function defines a saturation function. It limits a given input to an interval [dw_bnd, up_bnd]

double sign const double  x  )  [inline]
 

This function implements the signum function. It returns either -1, 0 or 1 depending on whether the input argument is negative, 0 or positive, respectively.


RHexLib Reference Documentation