52 #define M_PI 3.14159265359 60 template <
class T,
typename Real>
61 inline bool is_zero(
const T& _a, Real _eps)
62 {
return fabs(_a) < _eps; }
64 template <
class T1,
class T2,
typename Real>
65 inline bool is_eq(
const T1& a,
const T2& b, Real _eps)
68 template <
class T1,
class T2,
typename Real>
69 inline bool is_gt(
const T1& a,
const T2& b, Real _eps)
70 {
return (a > b) && !is_eq(a,b,_eps); }
72 template <
class T1,
class T2,
typename Real>
73 inline bool is_ge(
const T1& a,
const T2& b, Real _eps)
74 {
return (a > b) || is_eq(a,b,_eps); }
76 template <
class T1,
class T2,
typename Real>
77 inline bool is_lt(
const T1& a,
const T2& b, Real _eps)
78 {
return (a < b) && !is_eq(a,b,_eps); }
80 template <
class T1,
class T2,
typename Real>
81 inline bool is_le(
const T1& a,
const T2& b, Real _eps)
82 {
return (a < b) || is_eq(a,b,_eps); }
86 const float flt_eps__ = (float)1e-05;
87 const double dbl_eps__ = 1e-09;
89 inline float eps__(
float)
92 inline double eps__(
double)
97 {
return is_zero(a, eps__(a)); }
99 template <
class T1,
class T2>
100 inline bool is_eq(
const T1& a,
const T2& b)
103 template <
class T1,
class T2>
104 inline bool is_gt(
const T1& a,
const T2& b)
105 {
return (a > b) && !is_eq(a,b); }
107 template <
class T1,
class T2>
108 inline bool is_ge(
const T1& a,
const T2& b)
109 {
return (a > b) || is_eq(a,b); }
111 template <
class T1,
class T2>
112 inline bool is_lt(
const T1& a,
const T2& b)
113 {
return (a < b) && !is_eq(a,b); }
115 template <
class T1,
class T2>
116 inline bool is_le(
const T1& a,
const T2& b)
117 {
return (a < b) || is_eq(a,b); }
143 return (T) _sin_angle >= 0 ? acos(_cos_angle) : -acos(_cos_angle);
147 inline T positive_angle(T _angle)
148 {
return _angle < 0 ? (2*M_PI + _angle) : _angle; }
151 inline T positive_angle(T _cos_angle, T _sin_angle)
152 {
return positive_angle(
angle(_cos_angle, _sin_angle)); }
155 inline T deg_to_rad(
const T& _angle)
156 {
return M_PI*(_angle/180); }
159 inline T rad_to_deg(
const T& _angle)
160 {
return 180*(_angle/M_PI); }
162 inline double log_(
double _value)
163 {
return log(_value); }
T sane_aarg(T _aarg)
Trigonometry/angles - related.
T angle(T _cos_angle, T _sin_angle)
bool is_zero(const T &_a, Real _eps)