30 #ifndef vtkMathUtilities_h
31 #define vtkMathUtilities_h
45 return fabs(a - b) < std::numeric_limits<A>::epsilon();
54 return fabs(a - b) < epsilon;
70 if( (a == static_cast<A>(0)) ||
71 ((b > static_cast<A>(1)) && (a < b*std::numeric_limits<A>::min())) )
73 return static_cast<A
>(0);
86 bool NearlyEqual(A a, A b, A tol=std::numeric_limits<A>::epsilon())
88 A absdiff = fabs(a-b);
89 A d1 = vtkMathUtilities::SafeDivision<A>(absdiff,fabs(a));
90 A d2 = vtkMathUtilities::SafeDivision<A>(absdiff,fabs(b));
93 if( (d1 <= tol) || (d2 <= tol) )
102 #endif // vtkMathUtilities_h
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...
bool FuzzyCompare(A a, A b)
Perform a fuzzy compare of floats/doubles.
A SafeDivision(A a, A b)
Performs safe division that catches overflow and underflow.