HologramDepthmap Library
epsilon.cpp
Go to the documentation of this file.
1 #include "graphics/epsilon.h"
2 #include <math.h>
3 #include "graphics/sys.h"
4 
5 namespace graphics {
6 
7 real epsilon = 1.0e-8;
8 real user_epsilon = 1.0e-8;
10 real sqrt_epsilon = 1.490116119385000000e-8;
11 real unset_value = -1.23432101234321e+308;
12 real zero_tolerance = 1.0e-12;
13 real zero_epsilon = 1.0e-12;
16 
17 
18 /*|--------------------------------------------------------------------------*/
19 /*| Set user epsilon : Throughout the running program we could use the same */
20 /*| user epsilon defined here. Default user_epsilon is always 1e-8. */
21 /*|--------------------------------------------------------------------------*/
23 {
24  user_epsilon = a;
25 }
26 
28 {
29  user_epsilon = epsilon;
30 }
32 {
33  save_zero_epsilon = zero_epsilon;
34  zero_epsilon = a;
35 }
36 
38 {
39  zero_epsilon = save_zero_epsilon;
40 }
41 
42 /*|--------------------------------------------------------------------------*/
43 /*| Approximated version of checking equality : using epsilon */
44 /*|--------------------------------------------------------------------------*/
45 int apx_equal(real x, real y)
46 {
47  int c;
48  real a;
49 
50  a = fabsf((x) - (y)) ;
51 
52  if (a < user_epsilon) c = 1;
53  else c = 0;
54 
55  return c;
56 }
57 
58 /*|--------------------------------------------------------------------------*/
59 /*| Approximated version of checking equality : using epsilon */
60 /*|--------------------------------------------------------------------------*/
61 int apx_equal(real x, real y, real eps)
62 {
63  int c;
64  real a;
65 
66  a = fabsf((x) - (y)) ;
67 
68  if (a < eps) c = 1;
69  else c = 0;
70 
71  return c;
72 }
73 }; // namespace graphics
void set_zero_epsilon(real a)
Definition: epsilon.cpp:31
void reset_u_epsilon()
Definition: epsilon.cpp:27
void reset_zero_epsilon()
Definition: epsilon.cpp:37
real intersection_epsilon
Definition: epsilon.cpp:9
double real
Definition: real.h:4
real user_epsilon
Definition: epsilon.cpp:8
real epsilon
Definition: epsilon.cpp:7
real zero_epsilon
Definition: epsilon.cpp:13
real sqrt_epsilon
Definition: epsilon.cpp:10
int apx_equal(real x, real y)
Definition: epsilon.cpp:45
real save_zero_epsilon
Definition: epsilon.cpp:15
real angle_tolerance
Definition: epsilon.cpp:14
real zero_tolerance
Definition: epsilon.cpp:12
real unset_value
Definition: epsilon.cpp:11
#define M_PI
Definition: real.h:23
void set_u_epsilon(real a)
Definition: epsilon.cpp:22