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.2 by greg, Sun May 7 21:41:40 1989 UTC vs.
Revision 1.6 by greg, Tue Apr 2 15:27:44 1991 UTC

# Line 83 | Line 83 | register FVECT  vres, v1, v2;
83   }
84  
85  
86 + fvsum(vres, v0, v1, f)          /* vres = v0 + f*v1 */
87 + FVECT  vres, v0, v1;
88 + double  f;
89 + {
90 +        vres[0] = v0[0] + f*v1[0];
91 +        vres[1] = v0[1] + f*v1[1];
92 +        vres[2] = v0[2] + f*v1[2];
93 + }
94 +
95 +
96   double
97   normalize(v)                    /* normalize a vector, return old magnitude */
98   register FVECT  v;
# Line 91 | Line 101 | register FVECT  v;
101          
102          len = DOT(v, v);
103          
104 <        if (len <= FTINY*FTINY)
104 >        if (len <= 0.0)
105                  return(0.0);
106          
107          /****** problematic
# Line 105 | Line 115 | register FVECT  v;
115          v[1] /= len;
116          v[2] /= len;
117          return(len);
118 + }
119 +
120 +
121 + spinvector(vres, vorig, vnorm, theta)   /* rotate vector around normal */
122 + FVECT  vres, vorig, vnorm;
123 + double  theta;
124 + {
125 +        extern double  cos(), sin();
126 +        double  sint, cost, normprod;
127 +        FVECT  vperp;
128 +        register int  i;
129 +        
130 +        if (theta == 0.0) {
131 +                if (vres != vorig)
132 +                        VCOPY(vres, vorig);
133 +                return;
134 +        }
135 +        cost = cos(theta);
136 +        sint = sin(theta);
137 +        normprod = DOT(vorig, vnorm)*(1.-cost);
138 +        fcross(vperp, vnorm, vorig);
139 +        for (i = 0; i < 3; i++)
140 +                vres[i] = vorig[i]*cost + vnorm[i]*normprod + vperp[i]*sint;
141   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines