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; |
103 |
|
if (len <= 0.0) |
104 |
|
return(0.0); |
105 |
|
|
106 |
< |
/****** problematic |
107 |
< |
if (len >= (1.0-FTINY)*(1.0-FTINY) && |
108 |
< |
len <= (1.0+FTINY)*(1.0+FTINY)) |
109 |
< |
return(1.0); |
111 |
< |
******/ |
106 |
> |
if (len <= 1.0+FTINY && len >= 1.0-FTINY) |
107 |
> |
len = 0.5 + 0.5*len; /* first order approximation */ |
108 |
> |
else |
109 |
> |
len = sqrt(len); |
110 |
|
|
113 |
– |
len = sqrt(len); |
111 |
|
v[0] /= len; |
112 |
|
v[1] /= len; |
113 |
|
v[2] /= len; |
114 |
+ |
|
115 |
|
return(len); |
116 |
|
} |
117 |
|
|
120 |
|
FVECT vres, vorig, vnorm; |
121 |
|
double theta; |
122 |
|
{ |
125 |
– |
extern double cos(), sin(); |
123 |
|
double sint, cost, normprod; |
124 |
|
FVECT vperp; |
125 |
|
register int i; |