1 // This is brl/bbas/bmsh3d/bmsh3d_fuzzy_boolean.h
2 #ifndef bmsh3d_fuzzy_boolean_h__
3 #define bmsh3d_fuzzy_boolean_h__
4 //:
5 // \file
6 // \brief  bmsh3d fuzzy boolean functions.
7 // \author Ming-Ching Chang (mcchang@lems.brown.edu)
8 // \date   May/07/2007
9 //
10 // \verbatim
11 // \endverbatim
12 //
13 //-----------------------------------------------------------------------------
14 
15 #include <iostream>
16 #include <cmath>
17 #ifdef _MSC_VER
18 #  include <vcl_msvc_warnings.h>
19 #endif
20 
21 #define BMSH3D_FINE_EPSILON     5E-15
22 #define BMSH3D_MID_EPSILON      5E-10
23 #define BMSH3D_COARSE_EPSILON   5E-5
24 
25 //: the mid-epsilon equality test, use absolute test.
bmsh3d_eq(const double & a,const double & b,const double & epsilon)26 inline bool bmsh3d_eq (const double& a, const double& b, const double& epsilon)
27 {
28   return std::fabs(a-b) < epsilon;
29 }
30 
31 //: the mid-epsilon equality test, use absolute test.
bmsh3d_eq_m(const double & a,const double & b)32 inline bool bmsh3d_eq_m (const double& a, const double& b)
33 {
34   return std::fabs(a-b) < BMSH3D_MID_EPSILON;
35 }
36 
bmsh3d_leq_m(const double & a,const double & b)37 inline bool bmsh3d_leq_m (const double& a, const double& b)
38 {
39   return a < b || bmsh3d_eq_m (a, b);
40 }
41 
42 //: the coarse-epsilon equality test, use absolute test.
bmsh3d_eq_c(const double & a,const double & b)43 inline bool bmsh3d_eq_c (const double& a, const double& b)
44 {
45   return std::fabs(a-b) < BMSH3D_COARSE_EPSILON;
46 }
47 
48 #endif // bmsh3d_fuzzy_boolean_h__
49