The Cuik KD-Tree Library


definitions.h

Go to the documentation of this file.
00001 #ifndef DEFINITIONSH
00002 #define DEFINITIONSH
00003 
00013 #include <stdlib.h> /*The NEW macros call malloc,..*/
00014 #include <math.h>
00015 
00016 /************************************************************************************/
00017 /************************************************************************************/
00018 
00019 #ifndef M_PI
00020 
00024   #define M_PI 3.14159265358979323846
00025 #endif
00026 
00027 #ifndef M_2PI
00028 
00032   #define M_2PI (2.0*M_PI)
00033 #endif
00034 
00035 
00036 /************************************************************************************/
00037 /************************************************************************************/
00038 
00039 #ifndef SWAP
00040 
00049   #define SWAP(a,b,c) {c=a;a=b;b=c;}
00050 #endif
00051 
00052 /************************************************************************************/
00053 /************************************************************************************/
00054 
00055 #ifndef PI2PI
00056 
00064   #define PI2PI(a) {while(a>M_PI) a-=M_2PI; while (a<-M_PI) a+=M_2PI;}
00065 #endif
00066 
00067 /************************************************************************************/
00068 /************************************************************************************/
00069 
00070 #ifndef NEW
00071 
00076   #define NEW(_var,_n,_type) {(_var)=(_type *)malloc(sizeof(_type)*(_n)); \
00077                                if (!(_var)) exit(EXIT_FAILURE);}
00078 #endif
00079 
00080 #ifndef MEM_EXPAND
00081 
00088   #define MEM_EXPAND(_var,_n,_type) {(_var)=(_type *)realloc((void *)(_var),sizeof(_type)*(_n)); \
00089                                      if (!(_var)) exit(EXIT_FAILURE);}
00090 #endif
00091 
00092 #ifndef MEM_DUP
00093 
00101   #define MEM_DUP(_var,_n,_type) {(_n)*=2;MEM_EXPAND(_var,_n,_type);}
00102 #endif
00103 
00104 /************************************************************************************/
00105 /************************************************************************************/
00106 #ifndef NO_UINT
00107 
00111   #define NO_UINT ((unsigned int)(-1))
00112 #endif
00113  
00114 #ifndef INF
00115 
00119   #define INF 1e200
00120 #endif
00121 
00122 /************************************************************************************/
00123 /************************************************************************************/
00124 #ifndef boolean
00125 
00130   typedef unsigned int boolean; 
00131 #endif
00132 
00133 #ifndef TRUE
00134 
00139   #define TRUE  1
00140 #endif
00141 
00142 #ifndef FALSE
00143 
00148   #define FALSE 0
00149 #endif
00150 
00151 /************************************************************************************/
00152 /************************************************************************************/
00153 #ifndef TOPOLOGY_R
00154 
00158   #define TOPOLOGY_R 1
00159 #endif
00160 
00161 #ifndef TOPOLOGY_S
00162 
00166   #define TOPOLOGY_S 2
00167 #endif
00168 
00169 #endif