10 |
|
* 8/14/85 |
11 |
|
*/ |
12 |
|
|
13 |
+ |
#include <math.h> |
14 |
|
#include "fvect.h" |
15 |
|
|
15 |
– |
#define FTINY 1e-7 |
16 |
|
|
17 |
– |
|
17 |
|
double |
18 |
|
fdot(v1, v2) /* return the dot product of two vectors */ |
19 |
|
register FVECT v1, v2; |
121 |
|
FVECT vres, vorig, vnorm; |
122 |
|
double theta; |
123 |
|
{ |
124 |
< |
extern double sin(), cos(); |
126 |
< |
double sint, cost, dotp; |
124 |
> |
double sint, cost, normprod; |
125 |
|
FVECT vperp; |
126 |
|
register int i; |
127 |
|
|
128 |
|
if (theta == 0.0) { |
129 |
< |
VCOPY(vres, vorig); |
129 |
> |
if (vres != vorig) |
130 |
> |
VCOPY(vres, vorig); |
131 |
|
return; |
132 |
|
} |
134 |
– |
sint = sin(theta); |
133 |
|
cost = cos(theta); |
134 |
< |
dotp = DOT(vorig, vnorm); |
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] = vnorm[i]*dotp*(1.-cost) + |
140 |
< |
vorig[i]*cost + vperp[i]*sint; |
138 |
> |
vres[i] = vorig[i]*cost + vnorm[i]*normprod + vperp[i]*sint; |
139 |
|
} |