--- ray/src/common/fvect.h 2003/06/06 16:38:47 2.9 +++ ray/src/common/fvect.h 2014/12/04 05:26:27 2.17 @@ -1,4 +1,4 @@ -/* RCSid $Id: fvect.h,v 2.9 2003/06/06 16:38:47 schorsch Exp $ */ +/* RCSid $Id: fvect.h,v 2.17 2014/12/04 05:26:27 greg Exp $ */ /* * Declarations for floating-point vector operations. */ @@ -8,18 +8,18 @@ extern "C" { #endif -#include "copyright.h" - #ifdef SMLFLT -#define FLOAT float +#define RREAL float #define FTINY (1e-3) +#define FVFORMAT "%f %f %f" #else -#define FLOAT double +#define RREAL double #define FTINY (1e-6) +#define FVFORMAT "%lf %lf %lf" #endif #define FHUGE (1e10) -typedef FLOAT FVECT[3]; +typedef RREAL 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]) @@ -38,17 +38,27 @@ typedef FLOAT FVECT[3]; (vr)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2], \ (vr)[2]=(v1)[0]*(v2)[1]-(v1)[1]*(v2)[0]) +#define GEOD_RAD 0 /* geodesic distance specified in radians */ +#define GEOD_ABS 1 /* absolute geodesic distance */ +#define GEOD_REL 2 /* relative geodesic distance */ -extern double fdot(FVECT v1, FVECT v2); -extern double dist2(FVECT v1, FVECT v2); -extern double dist2line(FVECT p, FVECT ep1, FVECT ep2); -extern double dist2lseg(FVECT p, FVECT ep1, FVECT ep2); -extern void fcross(FVECT vres, FVECT v1, FVECT v2); -extern void fvsum(FVECT vres, FVECT v0, FVECT v1, double f); +extern double Acos(double x); +extern double Asin(double x); +extern double fdot(const FVECT v1, const FVECT v2); +extern double dist2(const FVECT v1, const FVECT v2); +extern double dist2line(const FVECT p, const FVECT ep1, const FVECT ep2); +extern double dist2lseg(const FVECT p, const FVECT ep1, const FVECT ep2); +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 void spinvector(FVECT vres, FVECT vorig, FVECT vnorm, double theta); - - +extern int getperpendicular(FVECT vp, const FVECT v); +extern int closestapproach(RREAL t[2], + const FVECT rorg0, const FVECT rdir0, + const FVECT rorg1, const FVECT rdir1); +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); #ifdef __cplusplus } #endif