195 |
|
) |
196 |
|
{ |
197 |
|
FVECT normtarg; |
198 |
< |
double volen, dotprod, sint, cost; |
198 |
> |
double volen, dotprod, sintr, cost; |
199 |
|
int i; |
200 |
|
|
201 |
+ |
VCOPY(normtarg, vtarg); /* in case vtarg==vres */ |
202 |
|
if (vres != vorig) |
203 |
|
VCOPY(vres, vorig); |
204 |
|
if (t == 0.0) |
205 |
|
return(VLEN(vres)); /* no rotation requested */ |
206 |
|
if ((volen = normalize(vres)) == 0.0) |
207 |
|
return(0.0); |
207 |
– |
VCOPY(normtarg, vtarg); |
208 |
|
if (normalize(normtarg) == 0.0) |
209 |
|
return(0.0); /* target vector is zero */ |
210 |
|
dotprod = DOT(vres, normtarg); |
222 |
|
else if (meas == GEOD_REL) |
223 |
|
t *= acos(dotprod); |
224 |
|
cost = cos(t); |
225 |
< |
sint = sin(t); |
225 |
> |
sintr = sin(t) / sqrt(1. - dotprod*dotprod); |
226 |
|
for (i = 0; i < 3; i++) |
227 |
|
vres[i] = volen*( cost*vres[i] + |
228 |
< |
sint*(normtarg[i] - dotprod*vres[i]) ); |
228 |
> |
sintr*(normtarg[i] - dotprod*vres[i]) ); |
229 |
|
|
230 |
|
return(volen); /* return vector length */ |
231 |
|
} |