VTK  9.4.20241123
Functions
vtkMathUtilities Namespace Reference

Functions

template<class A >
bool FuzzyCompare (A a, A b, A epsilon=std::numeric_limits< A >::epsilon())
 Perform a fuzzy compare of floats/doubles, specify the allowed tolerance NB: this uses an absolute tolerance.
 
template<class A >
SafeDivision (A a, A b)
 Performs safe division that catches overflow and underflow.
 
template<class A >
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, "The Art of Computer Programming (vol II)" NB: this uses a relative tolerance.
 
template<class A >
void UpdateRangeImpl (A &min0, A &max0, const A &value)
 Update an existing min - max range with a new prospective value.
 
template<class A >
void UpdateRange (A &min0, A &max0, const A &value, typename std::enable_if<!std::is_floating_point< A >::value >::type *=nullptr)
 
template<class A >
void UpdateRange (A &min0, A &max0, const A &value, typename std::enable_if< std::is_floating_point< A >::value >::type *=nullptr)
 

Function Documentation

◆ FuzzyCompare()

template<class A >
bool vtkMathUtilities::FuzzyCompare ( a,
b,
epsilon = std::numeric_limits<A>::epsilon() 
)

Perform a fuzzy compare of floats/doubles, specify the allowed tolerance NB: this uses an absolute tolerance.

Definition at line 37 of file vtkMathUtilities.h.

◆ SafeDivision()

template<class A >
A vtkMathUtilities::SafeDivision ( a,
b 
)

Performs safe division that catches overflow and underflow.

Definition at line 46 of file vtkMathUtilities.h.

◆ NearlyEqual()

template<class A >
bool vtkMathUtilities::NearlyEqual ( a,
b,
tol = std::numeric_limits<A>::epsilon() 
)

A slightly different fuzzy comparator that checks if two values are "nearly" equal based on Knuth, "The Art of Computer Programming (vol II)" NB: this uses a relative tolerance.

Definition at line 71 of file vtkMathUtilities.h.

◆ UpdateRangeImpl()

template<class A >
void vtkMathUtilities::UpdateRangeImpl ( A &  min0,
A &  max0,
const A &  value 
)

Update an existing min - max range with a new prospective value.

If the value is non NaN then the appropriate range comparisons are made and updated, otherwise the original min - max values are set.

Examples:

No change: UpdateRange(-100, 100, 20) -> (-100, 100)

Update min: UpdateRange(-100, 100, -200) -> (-200, 100)

Update max: UpdateRange(-100, 100, 200) -> (-100, 200)

Input min and max are inverted creating an invalid range so a new range with the specified value is set: UpdateRange(100, -100, 20) -> (20, 20)

Input value is NaN so the original range is set UpdateRange(-100, 100, NaN) -> (-100, 100)

Definition at line 104 of file vtkMathUtilities.h.

◆ UpdateRange() [1/2]

template<class A >
void vtkMathUtilities::UpdateRange ( A &  min0,
A &  max0,
const A &  value,
typename std::enable_if<!std::is_floating_point< A >::value >::type *  = nullptr 
)

Definition at line 120 of file vtkMathUtilities.h.

◆ UpdateRange() [2/2]

template<class A >
void vtkMathUtilities::UpdateRange ( A &  min0,
A &  max0,
const A &  value,
typename std::enable_if< std::is_floating_point< A >::value >::type *  = nullptr 
)

Definition at line 127 of file vtkMathUtilities.h.