Openholo  v4.2
Open Source Digital Holographic Library
epsilon.cpp
Go to the documentation of this file.
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install, copy or use the software.
7 //
8 //
9 // License Agreement
10 // For Open Source Digital Holographic Library
11 //
12 // Openholo library is free software;
13 // you can redistribute it and/or modify it under the terms of the BSD 2-Clause license.
14 //
15 // Copyright (C) 2017-2024, Korea Electronics Technology Institute. All rights reserved.
16 // E-mail : contact.openholo@gmail.com
17 // Web : http://www.openholo.org
18 //
19 // Redistribution and use in source and binary forms, with or without modification,
20 // are permitted provided that the following conditions are met:
21 //
22 // 1. Redistribution's of source code must retain the above copyright notice,
23 // this list of conditions and the following disclaimer.
24 //
25 // 2. Redistribution's in binary form must reproduce the above copyright notice,
26 // this list of conditions and the following disclaimer in the documentation
27 // and/or other materials provided with the distribution.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the copyright holder or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 // This software contains opensource software released under GNU Generic Public License,
41 // NVDIA Software License Agreement, or CUDA supplement to Software License Agreement.
42 // Check whether software you use contains licensed software.
43 //
44 //M*/
45 
46 #include "epsilon.h"
47 #include <math.h>
48 #include "sys.h"
49 #include "define.h"
50 
51 namespace oph {
52 
53 Real epsilon = 1.0e-8;
54 Real user_epsilon = 1.0e-8;
56 Real sqrt_epsilon = 1.490116119385000000e-8;
57 Real unset_value = -1.23432101234321e+308;
58 Real zero_tolerance = 1.0e-12;
59 Real zero_epsilon = 1.0e-12;
62 
63 
64 /*|--------------------------------------------------------------------------*/
65 /*| Set user epsilon : Throughout the running program we could use the same */
66 /*| user epsilon defined here. Default user_epsilon is always 1e-8. */
67 /*|--------------------------------------------------------------------------*/
69 {
70  user_epsilon = a;
71 }
72 
74 {
76 }
78 {
80  zero_epsilon = a;
81 }
82 
84 {
86 }
87 
88 /*|--------------------------------------------------------------------------*/
89 /*| Approximated version of checking equality : using epsilon */
90 /*|--------------------------------------------------------------------------*/
91 int apx_equal(Real x, Real y)
92 {
93  int c;
94  Real a;
95 
96  a = Real(fabsf(((float)x) - ((float)y)));
97 
98  if (a < user_epsilon) c = 1;
99  else c = 0;
100 
101  return c;
102 }
103 
104 /*|--------------------------------------------------------------------------*/
105 /*| Approximated version of checking equality : using epsilon */
106 /*|--------------------------------------------------------------------------*/
107 int apx_equal(Real x, Real y, Real eps)
108 {
109  int c;
110  Real a;
111 
112  a = Real(fabsf(((float)x) - ((float)y)));
113 
114  if (a < eps) c = 1;
115  else c = 0;
116 
117  return c;
118 }
119 }; // namespace graphics
#define M_PI
Definition: define.h:52
Real sqrt_epsilon
Definition: epsilon.cpp:56
Real user_epsilon
Definition: epsilon.cpp:54
Real save_zero_epsilon
Definition: epsilon.cpp:61
float Real
Definition: typedef.h:55
void reset_zero_epsilon()
Definition: epsilon.cpp:83
Real zero_tolerance
Definition: epsilon.cpp:58
Real epsilon
Definition: epsilon.cpp:53
Real unset_value
Definition: epsilon.cpp:57
int apx_equal(Real x, Real y)
Definition: epsilon.cpp:91
void reset_u_epsilon()
Definition: epsilon.cpp:73
Real zero_epsilon
Definition: epsilon.cpp:59
Real angle_tolerance
Definition: epsilon.cpp:60
void set_zero_epsilon(Real a)
Definition: epsilon.cpp:77
Real intersection_epsilon
Definition: epsilon.cpp:55
Definition: Bitmap.h:49
void set_u_epsilon(Real a)
Definition: epsilon.cpp:68