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 sin(), cos(); |
126 |
+ |
double sint, cost, dotp; |
127 |
+ |
FVECT vperp; |
128 |
+ |
register int i; |
129 |
+ |
|
130 |
+ |
if (theta == 0.0) { |
131 |
+ |
VCOPY(vres, vorig); |
132 |
+ |
return; |
133 |
+ |
} |
134 |
+ |
sint = sin(theta); |
135 |
+ |
cost = cos(theta); |
136 |
+ |
dotp = DOT(vorig, vnorm); |
137 |
+ |
fcross(vperp, vnorm, vorig); |
138 |
+ |
for (i = 0; i < 3; i++) |
139 |
+ |
vres[i] = vnorm[i]*dotp*(1.-cost) + |
140 |
+ |
vorig[i]*cost + vperp[i]*sint; |
141 |
+ |
} |