--- ray/src/common/fvect.c 1989/10/17 13:35:30 1.4 +++ ray/src/common/fvect.c 1991/10/23 13:43:15 1.7 @@ -12,9 +12,7 @@ static char SCCSid[] = "$SunId$ LBL"; #include "fvect.h" -#define FTINY 1e-7 - double fdot(v1, v2) /* return the dot product of two vectors */ register FVECT v1, v2; @@ -115,4 +113,27 @@ register FVECT v; v[1] /= len; v[2] /= len; return(len); +} + + +spinvector(vres, vorig, vnorm, theta) /* rotate vector around normal */ +FVECT vres, vorig, vnorm; +double theta; +{ + extern double cos(), sin(); + double sint, cost, normprod; + FVECT vperp; + register int i; + + if (theta == 0.0) { + if (vres != vorig) + VCOPY(vres, vorig); + return; + } + cost = cos(theta); + sint = sin(theta); + normprod = DOT(vorig, vnorm)*(1.-cost); + fcross(vperp, vnorm, vorig); + for (i = 0; i < 3; i++) + vres[i] = vorig[i]*cost + vnorm[i]*normprod + vperp[i]*sint; }