ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fvect.c
(Generate patch)

Comparing ray/src/common/fvect.c (file contents):
Revision 1.3 by greg, Mon May 8 08:40:56 1989 UTC vs.
Revision 2.1 by greg, Tue Nov 12 16:55:09 1991 UTC

# Line 12 | Line 12 | static char SCCSid[] = "$SunId$ LBL";
12  
13   #include  "fvect.h"
14  
15 #define  FTINY          1e-7
15  
17
16   double
17   fdot(v1, v2)                    /* return the dot product of two vectors */
18   register FVECT  v1, v2;
# Line 83 | Line 81 | register FVECT  vres, v1, v2;
81   }
82  
83  
84 + fvsum(vres, v0, v1, f)          /* vres = v0 + f*v1 */
85 + FVECT  vres, v0, v1;
86 + double  f;
87 + {
88 +        vres[0] = v0[0] + f*v1[0];
89 +        vres[1] = v0[1] + f*v1[1];
90 +        vres[2] = v0[2] + f*v1[2];
91 + }
92 +
93 +
94   double
95   normalize(v)                    /* normalize a vector, return old magnitude */
96   register FVECT  v;
# Line 105 | Line 113 | register FVECT  v;
113          v[1] /= len;
114          v[2] /= len;
115          return(len);
116 + }
117 +
118 +
119 + spinvector(vres, vorig, vnorm, theta)   /* rotate vector around normal */
120 + FVECT  vres, vorig, vnorm;
121 + double  theta;
122 + {
123 +        extern double  cos(), sin();
124 +        double  sint, cost, normprod;
125 +        FVECT  vperp;
126 +        register int  i;
127 +        
128 +        if (theta == 0.0) {
129 +                if (vres != vorig)
130 +                        VCOPY(vres, vorig);
131 +                return;
132 +        }
133 +        cost = cos(theta);
134 +        sint = sin(theta);
135 +        normprod = DOT(vorig, vnorm)*(1.-cost);
136 +        fcross(vperp, vnorm, vorig);
137 +        for (i = 0; i < 3; i++)
138 +                vres[i] = vorig[i]*cost + vnorm[i]*normprod + vperp[i]*sint;
139   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines