--- ray/src/cv/mgflib/fvect.c 1994/06/21 14:45:44 1.1 +++ ray/src/cv/mgflib/fvect.c 2003/02/28 20:11:29 1.4 @@ -1,14 +1,12 @@ -/* Copyright (c) 1994 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: fvect.c,v 1.4 2003/02/28 20:11:29 greg Exp $"; #endif - /* * Routines for 3-d vectors */ #include +#include #include #include "parser.h" @@ -19,12 +17,15 @@ register FVECT v; { static double len; - len = v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; + len = DOT(v, v); if (len <= 0.0) return(0.0); - len = sqrt(len); + if (len <= 1.0+FTINY && len >= 1.0-FTINY) + len = 0.5 + 0.5*len; /* first order approximation */ + else + len = sqrt(len); v[0] /= len; v[1] /= len; @@ -34,6 +35,7 @@ register FVECT v; } +void fcross(vres, v1, v2) /* vres = v1 X v2 */ register FVECT vres, v1, v2; {