VTK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkMathUtilities.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkMathUtilities.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
29 #ifndef __vtkMathUtilities_h
30 #define __vtkMathUtilities_h
31 
32 #include <cmath>
33 #include <limits>
34 
36 {
37 
39 
40 template<class A>
41 bool FuzzyCompare(A a, A b)
42 {
43  return fabs(a - b) < std::numeric_limits<A>::epsilon();
44 }
46 
48 
50 template<class A>
51 bool FuzzyCompare(A a, A b, A epsilon)
52 {
53  return fabs(a - b) < epsilon;
54 }
56 
57 } // End vtkMathUtilities namespace.
58 
59 #endif // __vtkMathUtilities_h
60 // VTK-HeaderTest-Exclude: vtkMathUtilities.h
bool FuzzyCompare(A a, A b)
templated utility math functions intended for internal use in tests etc.