HologramDepthmap Library
graphics
src
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;
9
real
intersection_epsilon
= 1e-6;
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;
14
real
angle_tolerance
=
M_PI
/180.0;
15
real
save_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
/*|--------------------------------------------------------------------------*/
22
void
set_u_epsilon
(
real
a)
23
{
24
user_epsilon = a;
25
}
26
27
void
reset_u_epsilon
()
28
{
29
user_epsilon =
epsilon
;
30
}
31
void
set_zero_epsilon
(
real
a)
32
{
33
save_zero_epsilon =
zero_epsilon
;
34
zero_epsilon = a;
35
}
36
37
void
reset_zero_epsilon
()
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
graphics::set_zero_epsilon
void set_zero_epsilon(real a)
Definition:
epsilon.cpp:31
graphics::reset_u_epsilon
void reset_u_epsilon()
Definition:
epsilon.cpp:27
graphics::reset_zero_epsilon
void reset_zero_epsilon()
Definition:
epsilon.cpp:37
graphics::intersection_epsilon
real intersection_epsilon
Definition:
epsilon.cpp:9
sys.h
real
double real
Definition:
real.h:4
graphics::user_epsilon
real user_epsilon
Definition:
epsilon.cpp:8
graphics::epsilon
real epsilon
Definition:
epsilon.cpp:7
graphics::zero_epsilon
real zero_epsilon
Definition:
epsilon.cpp:13
graphics::sqrt_epsilon
real sqrt_epsilon
Definition:
epsilon.cpp:10
graphics::apx_equal
int apx_equal(real x, real y)
Definition:
epsilon.cpp:45
graphics::save_zero_epsilon
real save_zero_epsilon
Definition:
epsilon.cpp:15
graphics::angle_tolerance
real angle_tolerance
Definition:
epsilon.cpp:14
epsilon.h
graphics
Definition:
epsilon.h:6
graphics::zero_tolerance
real zero_tolerance
Definition:
epsilon.cpp:12
graphics::unset_value
real unset_value
Definition:
epsilon.cpp:11
M_PI
#define M_PI
Definition:
real.h:23
graphics::set_u_epsilon
void set_u_epsilon(real a)
Definition:
epsilon.cpp:22
Generated by
1.8.13