home *** CD-ROM | disk | FTP | other *** search
- /*
- * inline vector operations, definitions:
- */
-
-
- #ifndef _VECTOR
- #define _VECTOR
-
- #define setvector(a,xx,yy,zz) ((a).x = xx, (a).y = yy, (a).z = zz)
-
- #define vdot(a,b) (((a).x * (b).x) + ((a).y * (b).y) + ((a).z*(b).z) )
- #define veclen(a) (sqrt(vdot((a),(a))))
- #define quickveclen(a) (ABS((a).x) + ABS((a).y) + ABS((a).z))
-
- #define svproduct(t, s, v) ((t).x = (s)*(v).x, (t).y= (v).y* (s), (t).z = (s)*(v).z)
- #define vadd(t, a, b) ((t).x = (a).x + (b).x, (t).y =(a).y + (b).y, (t).z = (a).z + (b).z)
- #define vcproduct(t, a, b) ((t).x = (a).x*(b).x, (t).y = (a).y*(b).y, (t).z = (a).z*(b).z)
- #define vneg(t,a) ((t).x = -(a).x, (t).y = -(a).y, (t).z = -(a).z)
- #define vsub(t, a, b) ((t).x = (a).x-(b).x, (t).y = (a).y-(b).y, (t).z = (a).z-(b).z)
-
- #ifdef DEBUG
- #define norm(t,a) (tmpdouble = veclen((a)), \
- (tmpdouble < EPSILON && (debug_options & DEBUGRUNTIME)) ? warning ("NNV %d %s ", __LINE__, __FILE__), setvector(t, 0,0,0) : \
- svproduct(t, 1/tmpdouble, (a)))
- #else
- #define norm(t,a) (tmpdouble = veclen((a)), \
- svproduct(t, 1/tmpdouble, (a)))
- #endif
-
-
- #define vabs(a,b) ((a).x = ABS((b).x), (a).y = ABS((b).y), (a).z = ABS((b).z))
-
- /* warning: don't use vcross(a,a,b) */
- #define vcross(t, a, b) ((t).x = (a).y*(b).z-(a).z*(b).y, \
- (t).y = (a).z*(b).x - (a).x*(b).z, (t).z = (a).x*(b).y-(a).y*(b).x)
-
- #endif
-