libmove3d  3.13.0
/home/slemaign/softs-local/BioMove3D-git/include/p3d_sys.h
00001 #ifndef XYT_SYS_H
00002 #define XYT_SYS_H
00003 
00004 #ifdef UNIX
00005 
00006         #include <stdio.h>
00007         #include <sys/types.h>
00008         #include <stdlib.h>
00009         #include <time.h>
00010         
00011 #elif defined WIN32
00012 
00013         #include <stdio.h>
00014         #include <stdlib.h>
00015         #include <time.h>
00016         #include <windows.h>
00017 
00018         #ifdef _DEBUG
00019                 #define __KD_DEBUG
00020                 #define PRINT_INFO
00021                 #define PRINT_ERROR
00022                 #define PRINT_WARNING
00023                 #define PRINT_DEBUG
00024         #endif
00025 
00026         /* if KCD_CP_IS_SOLID is 1, convex polyhedron as a solid instead of as a collection of convex facets in KCD
00027         #define CP_IS_SOLID */
00028 
00029         /* test with AABB around body of robot if KCD_USE_P3D_BODY_AABB is 1 */
00030         #define USE_P3D_BODY_AABB
00031 
00032         /* KCD with volume: also apply to robot iff KCD_APPROX_ROBOT is 1 */
00033 /*      #define APPROX_ROBOT */
00034 
00035         /* pour compiler sans solide qui fout sa zone dans purify */
00036 /*      #define SOLID_ACT */
00037 
00038         /* pour compiler sans icollide */
00039 /*      #define ICOLLID_ACT */
00040 
00041         /* pour compiler avec gjk afin de le debugger  */
00042 /*      #define GJK_DEBUG */
00043 
00044         /* write a file with OBB tree information (just for debugging) */
00045 /*      #define OBB_EVALUATION */
00046         
00047 #elif defined VXWORKS
00048 
00049         /* #include <vxWorks.h> */
00050         #include <stdio.h>
00051         #include <stdlib.h>
00052 #else
00053         #error Host platform must be defined !!
00054 #endif
00055 
00056 #include <math.h>
00057 #include <string.h>
00058 #include <stdbool.h>
00059 
00060 #ifndef M_PI
00061 #define M_PI    3.14159265358979323846
00062 #define M_PI_2  1.57079632679489661923
00063 #endif 
00064 
00065 #define M_2PI   6.2831853071795864769
00066 
00067 #define EPS1 0.1
00068 #define EPS2 0.01
00069 #define EPS3 0.001
00070 #define EPS4 0.0001
00071 #define EPS5 0.00001
00072 #define EPS6 0.000001
00073 #define EPS10 1e-10
00074  
00075 #define EPSILON 1e-10
00076 
00077 #define P3D_HUGE 1E10
00078 
00079 
00080 
00081 /*
00082  * Some usefull define
00083  */
00084 
00085 #ifndef TRUE
00086 #define TRUE  1
00087 #define FALSE 0
00088 #endif
00089 
00090 #ifndef NIL
00091 #define NIL 0
00092 #endif
00093 
00094 #ifndef NULL
00095 #define NULL 0
00096 #endif
00097 
00098 typedef double Float;
00099 
00100 /*
00101  * Some type definitions
00102  */
00103 typedef int     *PtrI;          /* pointer to an integer       */
00104 typedef int     (*PtrFct)();    /* pointer to integer function */
00105 typedef float   *PtrF;          /* pointer to a float          */
00106 
00107 
00108 /*
00109  * Some usefull macros
00110  */
00111 
00112 /* #define RTOD(r)      (r*57.29578049) */
00113 /* #define DTOR(d)      (d*0.017453292) */
00114 #define RTOD(r)      ((r)*180.0/M_PI)
00115 #define DTOR(d)      ((d)*M_PI/180.0)
00116 
00117 #define FUZZ         0.00001
00118 #define ABS(x)       (((x) >= 0.0) ? (x) : -(x))
00119 #ifndef MIN
00120 #define MIN(x,y)     (((x) < (y)) ? (x) : (y))
00121 #endif
00122 #ifndef MAX
00123 #define MAX(x,y)     (((x) > (y)) ? (x) : (y))
00124 #endif
00125 #define SQR(x) ((x)*(x))
00126 #define EQ(x,y)      (ABS((x)-(y)) < FUZZ)
00127 #define LEQ(x,y)     ((x)<(y) || EQ(x,y))
00128 #define GEQ(x,y)     ((x)>(y) || EQ(x,y))
00129 #define LNEQ(x,y)    (!GEQ(x,y))
00130 #define GNEQ(x,y)    (!LEQ(x,y))
00131 #define FEQ(x,y,f)   (ABS((x)-(y)) < f)
00132 #define FLEQ(x,y,f)  ((x)<(y) || FEQ(x,y,f))
00133 #define FGEQ(x,y,f)  ((x)>(y) || FEQ(x,y,f))
00134 #define DOT(u,v)     ((u)[0] * (v)[0] + (u)[1] * (v)[1] + (u)[2] * (v)[2])
00135 #define MAG(u)       sqrt(DOT(u,u))
00136 #ifndef SIGN
00137 #define SIGN(f)      (((f) < 0) ? (-1) : (1))
00138 #endif
00139 #define ROUND(f)     ((int) ( (f) + .5*SIGN(f)))
00140 #define MFLOOR(x)     ((int)x)
00141 #define MCEIL(x)      (x == floor(x) ? x : floor(x)+1)
00142 #define MOD(k,n)     ((k+n)%n)
00143 #define CLAMP(x,min,max)  (((x)<(min)) ? (min) : (((x)>(max)) ? (max) : (x)))
00144 #define INTERP(x,y,t) ((x) + ((y)-(x))*(t))
00145 #define VECEQ(u,v)    (EQ(u[0],v[0]) && EQ(u[1],v[1]) && EQ(u[2],v[2]))
00146 #define FVECEQ(u,v,f) (FEQ(u[0],v[0],f) && FEQ(u[1],v[1],f) && FEQ(u[2],v[2],f))
00147 #define cpvector(u,v) memcpy(u,v,3*sizeof(float))
00148 #define cpmatrix(u,v) memcpy(u,v,12*sizeof(float))
00149 
00150 
00151 
00152 /* Missing prototypes */
00153 
00154 extern int      fprintf(FILE *, const char *, ...);
00155 extern int      printf(const char *, ...);
00156 
00157 /*
00158  * for debugging 
00159  */
00160 #ifdef PRINT_INFO
00161 #define PrintInfo(p) (void)printf p
00162 #else
00163 #define PrintInfo(p) 
00164 #endif
00165 #ifdef PRINT_ERROR
00166 #define PrintError(p) { (void)printf("\n!!!! Error %s (line %i): ",__FILE__,__LINE__); (void)printf p; }
00167 #else
00168 #define PrintError(p) 
00169 #endif
00170 #ifdef PRINT_WARNING
00171 #define PrintWarning(p) (void)printf p
00172 #else
00173 #define PrintWarning(p) 
00174 #endif
00175 #ifdef PRINT_DEBUG
00176 #define PrintDebug(p) { (void)printf("\nDebug %s (line %i): ",__FILE__,__LINE__); (void)printf p; }
00177 #else
00178 #define PrintDebug(p) 
00179 #endif
00180 
00181 /*
00182  * For structure allocation. 
00183  */
00184 
00185 #define MY_ALLOC(type,n)     (type *) basic_alloc(n, sizeof(type))
00186 #define MY_FREE(ptr,type,n)  basic_free((void *)ptr, n, sizeof(type))
00187 #define MY_REALLOC(ptr,type,oldn,newn) (type *)basic_realloc((void *)ptr,oldn,newn,sizeof(type))
00188 #define MY_ALLOC_INFO(p)     basic_alloc_info(p)
00189 #define MY_STRDUP(str)       dyna_str_dup(str)
00190 #define MY_STRFREE(str)      dyna_str_free(str)
00191 #include "../util/proto/basic_alloc_proto.h"
00192 
00193 
00194 /*
00195  * For passing parameters to a function
00196  */
00197 #ifndef VAR_ARGS
00198 #define VAR_ARGS    v_arg1,v_arg2,v_arg3,v_arg4,v_arg5
00199 #endif
00200 
00201 typedef int      *ARGS;
00202 
00203 
00204 #endif
00205 
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines