22 return (((a) > 0.0) ? ((
int)((a) + 0.5)) : (((a) < 0.0) ? ((
int)((a)-0.5)) : 0));
32 return (((a) >= 0) ? (a) : (-(a)));
42 return (((a) >= 0.) ? (a) : (-(a)));
50 template <
class _T,
class _U>
53 return (((a) >= (b)) ? (a) : (b));
61 template <
class _T,
class _U>
64 return (((a) >= (_T)(b)) ? (b) : (a));
73 template <
class _T,
class _U,
class _V>
76 return (((a) >= (b)) ? (((a) >= (c)) ? (a) : (c)) : (((b) >= (c)) ? (b) : (c)));
85 template <
class _T,
class _U,
class _V>
88 return (((a) <= (b)) ? (((a) <= (c)) ? (a) : (c)) : (((b) <= (c)) ? (b) : (c)));
95 template <
typename _T>
96 inline _T
sqr(
const _T x)
108 template <
class _T,
class _U,
class _V,
class _W>
109 double Mdist(_T x1, _U y1, _V x2, _W y2)
111 return sqrt((
double)(
sqr(x1 - x2) +
sqr(y1 - y2)));
121 template <
class _T,
class _U,
class _V,
class _W>
124 return (
double)(
sqr(x1 - x2) +
sqr(y1 - y2));
136 template <
typename X1,
typename Y1,
typename Z1,
typename X2,
typename Y2,
typename Z2>
137 double Mdist(X1 x1, Y1 y1, Z1 z1, X2 x2, Y2 y2, Z2 z2)
139 return sqrt((
double)(
sqr(x1 - x2) +
sqr(y1 - y2) +
sqr(z1 - z2)));
149 template <
typename _T>
150 double MagSquared(_T
const x, _T
const y, _T
const z = 0, _T
const w = 0)
152 return (
double)(x * x + y * y + z * z + w * w);
162 template <
typename _T>
163 double Mag(_T
const x, _T
const y, _T
const z = 0, _T
const w = 0)
174 template <
typename _T>
175 _T
Clamp(_T a_in, _T a_min, _T a_max)
177 return Mmin(
Mmax(a_in, a_min), a_max);
192 template <
class _T,
class _U,
class _V>
195 return (std::abs((A) - (B)) <= std::abs(((A) + (B)) * (epsilon)));
204 template <
class _T,
class _U,
class _V>
207 return (((B) - (A)) > std::abs(((A) + (B)) * (epsilon)));
216 template <
class _T,
class _U,
class _V>
219 return (((A) - (B)) > std::abs(((A) + (B)) * (epsilon)));
228 template <
class _T,
class _U,
class _V>
231 return (
LT_EPS((A), (B), (epsilon)) ||
EQ_EPS((A), (B), (epsilon)));
240 template <
class _T,
class _U,
class _V>
243 return (
GT_EPS((A), (B), (epsilon)) ||
EQ_EPS((A), (B), (epsilon)));
264 template <
class _T,
class _U,
class _V>
265 bool EQ_TOL(
const _T& A,
const _U& B,
const _V& tolerance)
267 return (std::abs((A) - (B)) <= (tolerance));
276 template <
class _T,
class _U,
class _V>
279 return (((B) - (A)) > (tolerance));
288 template <
class _T,
class _U,
class _V>
291 return (((A) - (B)) > (tolerance));
300 template <
class _T,
class _U,
class _V>
303 return (
LT_TOL((A), (B), (tol)) ||
EQ_TOL((A), (B), (tol)));
312 template <
class _T,
class _U,
class _V>
315 return (
GT_TOL((A), (B), (tol)) ||
EQ_TOL((A), (B), (tol)));
bool LT_EPS(_T A, _U B, _V epsilon)
Returns true if A < B equal within an epsilon (DBL EPS).
bool GT_EPS(_T A, _U B, _V epsilon)
Returns true if A > B equal within an epsilon (DBL EPS).
_T Miabs(_T a)
Integer absolute value.
double Mag(_T const x, _T const y, _T const z=0, _T const w=0)
Magnituded sqrt(x*x + y*y + z*z + w*w)
bool LTEQ_TOL(_T A, _U B, _V tol)
Returns true if A <= B equal within a tolerance.
_T Mfabs(_T a)
Float absolute value.
double MagSquared(_T const x, _T const y, _T const z=0, _T const w=0)
Magnituded squared (x*x + y*y + z*z + w*w)
_T Mmax3(_T a, _U b, _V c)
Max of three values.
bool GTEQ_TOL(_T A, _U B, _V tol)
Returns true if A >= B equal within a tolerance.
double MdistSq(_T x1, _U y1, _V x2, _W y2)
XY distance squared.
_T sqr(const _T x)
Square.
_T Mmax(_T a, _U b)
Max of two values.
bool LTEQ_EPS(_T A, _U B, _V epsilon)
Returns true if A <= B equal within an epsilon (DBL EPS).
bool EQ_TOL(const _T &A, const _U &B, const _V &tolerance)
Returns true if A == B equal within a tolerance.
bool LT_TOL(_T A, _U B, _V tolerance)
Returns true if A < B equal within a tolerance.
double Mdist(_T x1, _U y1, _V x2, _W y2)
XY distance.
_T Mmin(_T a, _U b)
Min of two values.
_T Mmin3(_T a, _U b, _V c)
Min of three values.
bool GTEQ_EPS(_T A, _U B, _V epsilon)
Returns true if A >= B equal within an epsilon (DBL EPS).
bool GT_TOL(_T A, _U B, _V tolerance)
Returns true if A > B equal within a tolerance.
_T Clamp(_T a_in, _T a_min, _T a_max)
Returns a value between a_min and a_max.
bool EQ_EPS(_T A, _U B, _V epsilon)
Returns true if A == B within an epsilon (DBL EPS).