--- ray/src/common/fvect.h 2014/12/04 05:26:27 2.17 +++ ray/src/common/fvect.h 2021/12/13 21:05:00 2.22 @@ -1,4 +1,4 @@ -/* RCSid $Id: fvect.h,v 2.17 2014/12/04 05:26:27 greg Exp $ */ +/* RCSid $Id: fvect.h,v 2.22 2021/12/13 21:05:00 greg Exp $ */ /* * Declarations for floating-point vector operations. */ @@ -19,6 +19,14 @@ extern "C" { #endif #define FHUGE (1e10) +#define FABSEQ(x1,x2) (fabs((x1)-(x2)) <= FTINY) +#define FRELEQ(x1,x2) (fabs((x1)-(x2)) <= FTINY*0.5*(fabs(x1)+fabs(x2))) + +#define VABSEQ(v,w) (FABSEQ((v)[0],(w)[0]) && FABSEQ((v)[1],(w)[1]) \ + && FABSEQ((v)[2],(w)[2])) +#define VRELEQ(v,w) (FRELEQ((v)[0],(w)[0]) && FRELEQ((v)[1],(w)[1]) \ + && FRELEQ((v)[2],(w)[2])) + typedef RREAL FVECT[3]; #define VCOPY(v1,v2) ((v1)[0]=(v2)[0],(v1)[1]=(v2)[1],(v1)[2]=(v2)[2]) @@ -33,6 +41,9 @@ typedef RREAL FVECT[3]; #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 VLERP(vr,v1,a,v2) ((vr)[0]=(1.-(a))*(v1)[0]+(a)*(v2)[0], \ + (vr)[1]=(1.-(a))*(v1)[1]+(a)*(v2)[1], \ + (vr)[2]=(1.-(a))*(v1)[2]+(a)*(v2)[2]) #define VCROSS(vr,v1,v2) \ ((vr)[0]=(v1)[1]*(v2)[2]-(v1)[2]*(v2)[1], \ (vr)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2], \ @@ -51,7 +62,7 @@ extern double dist2lseg(const FVECT p, const FVECT ep1 extern void fcross(FVECT vres, const FVECT v1, const FVECT v2); extern void fvsum(FVECT vres, const FVECT v0, const FVECT v1, double f); extern double normalize(FVECT v); -extern int getperpendicular(FVECT vp, const FVECT v); +extern int getperpendicular(FVECT vp, const FVECT v, int randomize); extern int closestapproach(RREAL t[2], const FVECT rorg0, const FVECT rdir0, const FVECT rorg1, const FVECT rdir1); @@ -59,8 +70,10 @@ extern void spinvector(FVECT vres, const FVECT vorig, const FVECT vnorm, double theta); extern double geodesic(FVECT vres, const FVECT vorig, const FVECT vtarg, double t, int meas); + /* defined in disk2square.c */ +extern void SDsquare2disk(double ds[2], double seedx, double seedy); +extern void SDdisk2square(double sq[2], double diskx, double disky); #ifdef __cplusplus } #endif #endif /* _RAD_FVECT_H_ */ -