--- ray/src/cv/mgflib/parser.h 1994/06/22 15:33:42 1.2 +++ ray/src/cv/mgflib/parser.h 1994/06/23 07:48:36 1.4 @@ -141,14 +141,27 @@ extern int isflt(char *); /* non-zero if floating poi * Definitions for 3-d vector manipulation functions */ -#ifdef SMLFLT -#define FLOAT float +#ifdef SMLFLT +#define FLOAT float +#define FTINY (1e-3) #else -#define FLOAT double +#define FLOAT double +#define FTINY (1e-6) #endif +#define FHUGE (1e10) typedef FLOAT FVECT[3]; +#define VCOPY(v1,v2) ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1],(v1)[2]=(v2)[2]) +#define DOT(v1,v2) ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2]) +#define VSUM(vr,v1,v2,f) ((vr)[0]=(v1)[0]+(f)*(v2)[0], \ + (vr)[1]=(v1)[1]+(f)*(v2)[1], \ + (vr)[2]=(v1)[2]+(f)*(v2)[2]) + +#define is0vect(v) (DOT(v,v) < FTINY*FTINY) + +#define round0(x) if (x <= FTINY && x >= -FTINY) x = 0 + #ifdef NOPROTO extern double normalize(); /* normalize a vector */ #else @@ -185,6 +198,9 @@ typedef struct { FVECT p, n; /* point and normal */ } C_VERTEX; /* vertex context */ +#define isgrey(cxy) ((cxy)->cx > .31 && (cxy)->cx < .35 && \ + (cxy)->cy > .31 && (cxy)->cy < .35) + #define C_DEFCOLOR {.333,.333} #define C_DEFMATERIAL {NULL,1,0.,C_DEFCOLOR,0.,C_DEFCOLOR,0.,C_DEFCOLOR,\ 0.,C_DEFCOLOR,0.,0.,C_DEFCOLOR,0.} @@ -329,3 +345,4 @@ extern double atof(); extern MEM_PTR malloc(); extern MEM_PTR calloc(); extern MEM_PTR realloc(); +extern void free();