Back to index

radiance  4R0+20100331
fvect.h
Go to the documentation of this file.
00001 /* RCSid $Id: fvect.h,v 2.12 2003/09/16 06:30:20 greg Exp $ */
00002 /*
00003  * Declarations for floating-point vector operations.
00004  */
00005 #ifndef _RAD_FVECT_H_
00006 #define _RAD_FVECT_H_
00007 #ifdef __cplusplus
00008 extern "C" {
00009 #endif
00010 
00011 #ifdef  SMLFLT
00012 #define  RREAL              float
00013 #define  FTINY              (1e-3)
00014 #else
00015 #define  RREAL              double
00016 #define  FTINY              (1e-6)
00017 #endif
00018 #define  FHUGE              (1e10)
00019 
00020 typedef RREAL  FVECT[3];
00021 
00022 #define  VCOPY(v1,v2)       ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1],(v1)[2]=(v2)[2])
00023 #define  DOT(v1,v2)  ((v1)[0]*(v2)[0]+(v1)[1]*(v2)[1]+(v1)[2]*(v2)[2])
00024 #define  VLEN(v)     sqrt(DOT(v,v))
00025 #define  VADD(vr,v1,v2)     ((vr)[0]=(v1)[0]+(v2)[0], \
00026                             (vr)[1]=(v1)[1]+(v2)[1], \
00027                             (vr)[2]=(v1)[2]+(v2)[2])
00028 #define  VSUB(vr,v1,v2)     ((vr)[0]=(v1)[0]-(v2)[0], \
00029                             (vr)[1]=(v1)[1]-(v2)[1], \
00030                             (vr)[2]=(v1)[2]-(v2)[2])
00031 #define  VSUM(vr,v1,v2,f)   ((vr)[0]=(v1)[0]+(f)*(v2)[0], \
00032                             (vr)[1]=(v1)[1]+(f)*(v2)[1], \
00033                             (vr)[2]=(v1)[2]+(f)*(v2)[2])
00034 #define  VCROSS(vr,v1,v2) \
00035                      ((vr)[0]=(v1)[1]*(v2)[2]-(v1)[2]*(v2)[1], \
00036                      (vr)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2], \
00037                      (vr)[2]=(v1)[0]*(v2)[1]-(v1)[1]*(v2)[0])
00038 
00039 
00040 extern double fdot(FVECT v1, FVECT v2);
00041 extern double dist2(FVECT v1, FVECT v2);
00042 extern double dist2line(FVECT p, FVECT ep1, FVECT ep2);
00043 extern double dist2lseg(FVECT p, FVECT ep1, FVECT ep2);
00044 extern void   fcross(FVECT vres, FVECT v1, FVECT v2);
00045 extern void   fvsum(FVECT vres, FVECT v0, FVECT v1, double f);
00046 extern double normalize(FVECT v);
00047 extern int    closestapproach(RREAL t[2], FVECT rorg0, FVECT rdir0,
00048                             FVECT rorg1, FVECT rdir1);
00049 extern void   spinvector(FVECT vres, FVECT vorig, FVECT vnorm, double theta);
00050 
00051 
00052 #ifdef __cplusplus
00053 }
00054 #endif
00055 #endif /* _RAD_FVECT_H_ */
00056