The Cuik KD-Tree Library


definitions.h
Go to the documentation of this file.
1 #ifndef DEFINITIONSH
2 #define DEFINITIONSH
3 
13 #include <stdlib.h> /*The NEW macros call malloc,..*/
14 #include <math.h>
15 
16 /************************************************************************************/
17 /************************************************************************************/
18 
19 #ifndef M_PI
20 
24  #define M_PI 3.14159265358979323846
25 #endif
26 
27 #ifndef M_2PI
28 
32  #define M_2PI (2.0*M_PI)
33 #endif
34 
35 
36 /************************************************************************************/
37 /************************************************************************************/
38 #ifndef ANGLE_ACCURACY
39 
44  #define ANGLE_ACCURACY 1e-4
45 #endif
46 
47 /************************************************************************************/
48 /************************************************************************************/
49 
50 #ifndef SWAP
51 
60  #define SWAP(a,b,c) {c=a;a=b;b=c;}
61 #endif
62 
63 /************************************************************************************/
64 /************************************************************************************/
65 
66 #ifndef PI2PI
67 
75  #define PI2PI(a) { if ((a<-M_PI)||(a>M_PI)) { while(a>M_PI) a-=M_2PI; while (a<-M_PI) a+=M_2PI; }}
76 #endif
77 
78 /************************************************************************************/
79 /************************************************************************************/
80 
81 #ifndef NEW
82 
87  #define NEW(_var,_n,_type) {(_var)=(_type *)malloc(sizeof(_type)*(_n)); \
88  if (!(_var)) exit(EXIT_FAILURE);}
89 #endif
90 
91 #ifndef NEWZ
92 
98 #define NEWZ(_var,_n,_type) {(_var)=(_type *)calloc(_n,sizeof(_type)); \
99  if (!(_var)) exit(EXIT_FAILURE);}
100 #endif
101 
102 #ifndef MEM_EXPAND
103 
110  #define MEM_EXPAND(_var,_n,_type) {(_var)=(_type *)realloc((void *)(_var),sizeof(_type)*(_n)); \
111  if (!(_var)) exit(EXIT_FAILURE);}
112 #endif
113 
114 #ifndef MEM_DUP
115 
123  #define MEM_DUP(_var,_n,_type) {(_n)*=2;MEM_EXPAND(_var,_n,_type);}
124 #endif
125 
126 /************************************************************************************/
127 /************************************************************************************/
128 #ifndef NO_UINT
129 
133  #define NO_UINT ((unsigned int)(-1))
134 #endif
135 
136 #ifndef INF
137 
141  #define INF 1e200
142 #endif
143 
144 /************************************************************************************/
145 /************************************************************************************/
146 #ifndef boolean
147 
152  typedef unsigned int boolean;
153 #endif
154 
155 #ifndef TRUE
156 
161  #define TRUE 1
162 #endif
163 
164 #ifndef FALSE
165 
170  #define FALSE 0
171 #endif
172 
173 /************************************************************************************/
174 /************************************************************************************/
175 #ifndef TOPOLOGY_R
176 
180  #define TOPOLOGY_R 1
181 #endif
182 
183 #ifndef TOPOLOGY_S
184 
188  #define TOPOLOGY_S 2
189 #endif
190 
191 #endif
unsigned int boolean
Boolean type.
Definition: definitions.h:152