OpenLexocad  27.0
Precision.h
Go to the documentation of this file.
1 
8 #ifndef BASE_PRECISION_H
9 #define BASE_PRECISION_H
10 
11 #include <boost/math/special_functions/next.hpp>
12 #include <limits>
13 
14 
15 
16 #define L_RES 1.e-6
17 #define A_RES 1.e-10
18 
19 
20 namespace Geom
21 {
22 class Precision
23 {
24 public:
25  // Compare 2 points, samePoint etc, same as acsi: SPAresabs
26  static inline const double linear_Resolution() { return L_RES; }
27  // minimal angle, parallel, same as acis: SPAresnor
28  static inline const double angle_Resolution() { return A_RES; }
29 
30  static inline const double tolerance() { return L_RES; }
31 
32  static inline const double confusion() { return L_RES; }
33 
34  static inline const double angular() { return A_RES; }
35 
36 
37 
38  static inline double infinite() { return std::numeric_limits<double>::infinity(); }
39 
42  static inline double shape_infinite() { return 1E06; }
43 
44  // Note:
45  // If you want to use the std::numeric_limits min/max feature,
46  // you need to undefine the symbols named min and max first.
47  // These macros probably come from the windows.h.
48  // (tp) 20111213
49 
50  static inline double min_double()
51  {
52  // return std::numeric_limits<double>::min();
53  return DBL_MIN;
54  }
55 
56  static inline double max_double()
57  {
58  // return std::numeric_limits<double>::max();
59  return DBL_MAX;
60  }
61 
66  static inline double epsilon() { return std::numeric_limits<double>::epsilon(); }
67 
73  static inline double epsilon(double v)
74  {
75  if (v >= 0.0)
76  return boost::math::nextafter(v, max_double()) - v;
77  else
78  return v - boost::math::nextafter(v, min_double());
79  }
80 };
81 
82 
83 } // namespace Geom
84 
85 
86 
87 #endif
Definition: Rotation.h:5
static double infinite()
Definition: Precision.h:38
Definition: Precision.h:22
static double epsilon()
Definition: Precision.h:66
#define A_RES
Definition: Precision.h:17
static const double tolerance()
Definition: Precision.h:30
static const double confusion()
Definition: Precision.h:32
static const double linear_Resolution()
Definition: Precision.h:26
static const double angular()
Definition: Precision.h:34
static double epsilon(double v)
Definition: Precision.h:73
#define L_RES
Definition: Precision.h:16
static const double angle_Resolution()
Definition: Precision.h:28
static double min_double()
Definition: Precision.h:50
static double shape_infinite()
Definition: Precision.h:42
static double max_double()
Definition: Precision.h:56