9 #define M_PI 3.14159265359 12 #define M_1_PI (1/M_PI) 15 #define M_E 2.718281828 18 #define M_SQRT2PI 2.5066283 21 inline int absint(
int v) {
return v<0 ? -v : v;}
24 bool clamp(T& x, T& y,
const T x0,
const T y0,
const T x1,
const T y1)
27 if(x<x0) { ret =
true; x = x0;}
28 if(x>x1) { ret =
true; x = x1;}
29 if(y<y0) { ret =
true; y = y0;}
30 if(y>y1) { ret =
true; y = y1;}
48 #define frand(max) (((float)rand())*(max)/RAND_MAX) 49 #define FRAND1 (((float)rand())/RAND_MAX) 63 }
while (r2 > 1.0 || r2 == 0);
65 return y *
sqrt (-2.0 * log (r2) / r2);
69 return exp(-x*x/(2*stdev*stdev)) / (stdev*
M_SQRT2PI);
72 return exp(-x2/(2*stdev*stdev)) / (stdev*
M_SQRT2PI);
75 return exp(-x*x/(2*stdev*stdev)) / (stdev*
M_SQRT2PI);
78 return exp(-x2/(2*stdev*stdev)) / (stdev*
M_SQRT2PI);
82 int d=(int)a/360 - (
int)(a<0);
83 return a-360*(float)d;
87 float ashift = a-mina;
88 int d=(int)ashift/360 - (
int)(ashift<0);
89 return a-360*(float)d;
94 return a<=180 ? a : a-360;
98 float turns=floor(a*(0.5*
M_1_PI));
99 return a-(2*
M_PI)*turns;
103 float turns=floor((a-mina)*(0.5*
M_1_PI));
104 return a-(2*
M_PI)*turns;
114 return (a-cnta>
M_PI) ? a-(2*
M_PI) : a;
119 return 1<< int(ceil(log(
float(x))/log(2.f)));
float gaussd2(float x2, double stdev)
bool clamp(T &x, T &y, const T x0, const T y0, const T x1, const T y1)
float gauss2(float x2, float stdev)
float mapAngle2PI(float a)
float mapAngle180(float a)
float mapAngle360(float a)
double gaussd(float x, double stdev)
float gauss(float x, float stdev)
DMatrix< T > stdev(const DMatrix< T > &mat)
float mapAnglePI(float a)
DMatrix< T > & sqrt(DMatrix< T > &mat)