53 #include <visp/vpConfig.h>
57 #ifdef WIN32 // Not defined in Microsoft math.h
60 # define M_PI 3.14159265358979323846f
64 # define M_PI_2 (M_PI/2.f)
68 # define M_PI_4 (M_PI/4.f)
93 static inline double deg(
double rad) {
return (rad*180.0)/M_PI ; }
100 static inline double rad(
double deg) {
return (deg*M_PI)/180.0 ; }
106 static inline double sqr(
double x) {
return x*x ; }
109 static inline double fact(
unsigned int x) ;
112 static inline long double comb(
unsigned int n,
unsigned int p) ;
115 static inline int round(
const double x) ;
118 static inline int sign(
double x) ;
122 static inline bool nul(
double x,
double s=0.001);
125 static inline bool equal(
double x,
double y,
double s=0.001);
128 static inline bool greater(
double x,
double y,
double s=0.001);
137 template <
class Type>
static Type
maximum(
const Type& a,
const Type& b)
139 return (a > b) ? a : b;
148 template <
class Type>
static Type
minimum(
const Type& a,
const Type& b)
150 return (a < b) ? a : b;
158 template <
class Type>
static Type
abs(
const Type& x)
160 return (x < 0) ? -x : x;
165 static inline double sinc(
double x) ;
166 static inline double sinc(
double sinx,
double x) ;
167 static inline double mcosc(
double cosx,
double x) ;
168 static inline double msinc(
double sinx,
double x) ;
171 static inline double sigmoid(
double x,
double x0=0.,
double x1=1.,
double n=12.);
179 template <
class Type>
static void swap(Type& a, Type& b)
187 static const double ang_min_sinc;
188 static const double ang_min_mc;
201 if ( (x == 1) || (x == 0))
return 1;
202 return x *
fact(x-1);
215 if (n == p)
return 1;
232 if ((x-(
int)x) <= 0.5)
return (
int)x ;
233 else return (
int)x+1 ;
237 if (fabs(x-(
int)x) <= 0.5)
return (
int)x ;
238 else return (
int)x-1 ;
250 if (fabs(x) < 1e-15)
return 0 ;
else
252 if (x<0)
return -1 ;
else return 1 ;
277 return(
nul(x-y, s) );
303 if (fabs(x) < ang_min_sinc)
return 1.0 ;
304 else return sin(x)/x ;
318 if (fabs(x) < ang_min_sinc)
return 1.0 ;
319 else return (sinx/x) ;
333 if (fabs(x) < ang_min_mc)
return 0.5 ;
334 else return ((1.0-cosx)/x/x) ;
349 if (fabs(x) < ang_min_mc)
return (1./6.0) ;
350 else return ((1.0-sinx/x)/x/x) ;
369 double l0 = 1./(1.+exp(0.5*n));
370 double l1 = 1./(1.+exp(-0.5*n));
371 return (1./(1.+exp(-n*((x-x0)/(x1-x0)-0.5)))-l0)/(l1-l0);
static void swap(Type &a, Type &b)
static double sigmoid(double x, double x0=0., double x1=1., double n=12.)
static bool equal(double x, double y, double s=0.001)
Provides simple mathematics computation tools that are not available in the C mathematics library (ma...
static double fact(unsigned int x)
static int round(const double x)
static double sinc(double x)
static Type abs(const Type &x)
static Type maximum(const Type &a, const Type &b)
static bool nul(double x, double s=0.001)
static double mcosc(double cosx, double x)
static double sqr(double x)
static Type minimum(const Type &a, const Type &b)
static double rad(double deg)
static long double comb(unsigned int n, unsigned int p)
static double deg(double rad)
static bool greater(double x, double y, double s=0.001)
static int sign(double x)
static double msinc(double sinx, double x)