--- ray/src/common/fvect.c 1991/10/23 13:43:15 1.7 +++ ray/src/common/fvect.c 1993/12/10 09:53:30 2.3 @@ -10,6 +10,7 @@ static char SCCSid[] = "$SunId$ LBL"; * 8/14/85 */ +#include #include "fvect.h" @@ -102,16 +103,15 @@ register FVECT v; if (len <= 0.0) return(0.0); - /****** problematic - if (len >= (1.0-FTINY)*(1.0-FTINY) && - len <= (1.0+FTINY)*(1.0+FTINY)) - return(1.0); - ******/ + if (len <= 1.0+FTINY && len >= 1.0-FTINY) + len = 0.5 + 0.5*len; /* first order approximation */ + else + len = sqrt(len); - len = sqrt(len); v[0] /= len; v[1] /= len; v[2] /= len; + return(len); } @@ -120,7 +120,6 @@ spinvector(vres, vorig, vnorm, theta) /* rotate vector FVECT vres, vorig, vnorm; double theta; { - extern double cos(), sin(); double sint, cost, normprod; FVECT vperp; register int i;