VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkMathUtilities.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00015 00029 #ifndef __vtkMathUtilities_h 00030 #define __vtkMathUtilities_h 00031 00032 #include <cmath> 00033 #include <limits> 00034 00035 namespace vtkMathUtilities 00036 { 00037 00039 00040 template<class A> 00041 bool FuzzyCompare(A a, A b) 00042 { 00043 return fabs(a - b) < std::numeric_limits<A>::epsilon(); 00044 } 00046 00048 00050 template<class A> 00051 bool FuzzyCompare(A a, A b, A epsilon) 00052 { 00053 return fabs(a - b) < epsilon; 00054 } 00056 00057 } // End vtkMathUtilities namespace. 00058 00059 #endif // __vtkMathUtilities_h 00060 // VTK-HeaderTest-Exclude: vtkMathUtilities.h