27#ifndef vtkMathUtilities_h
28#define vtkMathUtilities_h
42bool FuzzyCompare(A a, A b, A epsilon = std::numeric_limits<A>::epsilon())
44 return fabs(a - b) < epsilon;
54 if ((b <
static_cast<A
>(1)) && (a > b * std::numeric_limits<A>::max()))
56 return std::numeric_limits<A>::max();
60 if ((a ==
static_cast<A
>(0)) ||
61 ((b >
static_cast<A
>(1)) && (a < b * std::numeric_limits<A>::min())))
63 return static_cast<A
>(0);
75bool NearlyEqual(A a, A b, A tol = std::numeric_limits<A>::epsilon())
77 A absdiff = fabs(a - b);
81 return ((d1 <= tol) || (d2 <= tol));
114 max0 = max0 < value ? value : max0;
116 else if (value > max0)
118 min0 = min0 > value ? value : min0;
125 typename std::enable_if<!std::is_floating_point<A>::value>::type* = 0)
132 typename std::enable_if<std::is_floating_point<A>::value>::type* = 0)
134 if (!std::isnan(value))
void UpdateRange(A &min0, A &max0, const A &value, typename std::enable_if<!std::is_floating_point< A >::value >::type *=0)
void UpdateRangeImpl(A &min0, A &max0, const A &value)
Update an existing min - max range with a new prospective value.
bool NearlyEqual(A a, A b, A tol=std::numeric_limits< A >::epsilon())
A slightly different fuzzy comparator that checks if two values are "nearly" equal based on Knuth,...
A SafeDivision(A a, A b)
Performs safe division that catches overflow and underflow.
bool FuzzyCompare(A a, A b, A epsilon=std::numeric_limits< A >::epsilon())
Perform a fuzzy compare of floats/doubles, specify the allowed tolerance.