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 useful functions and macros for common mathematical operations

#include <math.h>
#include "cdl/sim_defs.hh"

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)


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

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.


SimLib Reference Documentation