9 static T pi() { return T(3.1415926535897932384626433832795029L); }
10 static T min(const T& a, const T& b)
11 { return a < b ? a : b; }
12 static T min(const T& a, const T& b, const T& c)
13 { return min(min(a, b), c); }
14 static T min(const T& a, const T& b, const T& c, const T& d)
15 { return min(min(min(a, b), c), d); }
16 static T max(const T& a, const T& b)
17 { return a > b ? a : b; }
18 static T max(const T& a, const T& b, const T& c)
19 { return max(max(a, b), c); }
20 static T max(const T& a, const T& b, const T& c, const T& d)
21 { return max(max(max(a, b), c), d); }
22 static int sign(const T& a)
24 if (a < -SGLimits<T>::min())
26 else if (SGLimits<T>::min() < a)
32 static T rad2deg(const T& val)
33 { return val*180/pi(); }
34 static T deg2rad(const T& val)
35 { return val*pi()/180; }
38 /// Returns true if v is a NaN value
39 /// Use with care: allways code that you do not need to use that!
40 static bool isNaN(const T& v)
44 #elif defined HAVE_STD_ISNAN
47 // Use that every compare involving a NaN returns false
48 // But be careful, some usual compiler switches like for example
49 // -fast-math from gcc might optimize that expression to v != v which
50 // behaves exactly like the opposite ...
57 typedef SGMisc<float> SGMiscf;
58 typedef SGMisc<double> SGMiscd;