10 #ifndef VSR_MATH_INCLUDED
11 #define VSR_MATH_INCLUDED
19 static double sinc(
double x);
20 static double sinhc(
double x);
21 static double clamp(
double x,
double min,
double max);
22 static double map(
double x,
double min,
double max,
double rmin,
double rmax);
24 static int bitcount(
int x);
27 inline static bool Range(T v, T low, T high){
28 return ( v >= low && v <= high) ?
true :
false;
32 inline static bool Error(T v, T goal, T error){
33 return Range(v, goal - error, goal + error);
41 inline double Math::sinc(
double x) {
42 if (FERROR(x))
return 1;
else return sin(x)/(x);
45 inline double Math::sinhc(
double x) {
46 if (FERROR(x))
return 1;
else return sinh(x)/x;
49 inline double Math::clamp(
double x,
double min,
double max){
50 return (x < min) ? min : (x > max ) ? max : x;
53 inline double Math::map(
double x,
double min,
double max,
double rmin,
double rmax){
54 double orange = max - min;
55 double drange = rmax - rmin;
57 double offset = x - min;
58 double ratio = offset / orange;
60 double doffset = ratio * drange;
62 return rmin + doffset;
65 inline int Math::bitcount(
int x){
Definition: vsr_math.h:17
the versor library namespace
Definition: vsr_algebra.h:29