| 10 |
|
#define _USE_MATH_DEFINES |
| 11 |
|
#include <math.h> |
| 12 |
|
#include "fvect.h" |
| 13 |
+ |
#include "random.h" |
| 14 |
|
|
| 15 |
|
double |
| 16 |
|
Acos(double x) /* insurance for touchy math library */ |
| 148 |
|
return(len); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
+ |
|
| 152 |
+ |
int |
| 153 |
+ |
getperpendicular( /* choose random perpedicular direction */ |
| 154 |
+ |
FVECT vp, /* returns normalized */ |
| 155 |
+ |
const FVECT v /* input vector must be normalized */ |
| 156 |
+ |
) |
| 157 |
+ |
{ |
| 158 |
+ |
FVECT v1; |
| 159 |
+ |
int i; |
| 160 |
+ |
/* randomize other coordinates */ |
| 161 |
+ |
v1[0] = 0.5 - frandom(); |
| 162 |
+ |
v1[1] = 0.5 - frandom(); |
| 163 |
+ |
v1[2] = 0.5 - frandom(); |
| 164 |
+ |
for (i = 3; i--; ) |
| 165 |
+ |
if ((-0.6 < v[i]) & (v[i] < 0.6)) |
| 166 |
+ |
break; |
| 167 |
+ |
if (i < 0) |
| 168 |
+ |
return(0); |
| 169 |
+ |
v1[i] = 1.0; |
| 170 |
+ |
VCROSS(vp, v1, v); |
| 171 |
+ |
return(normalize(vp) > 0.0); |
| 172 |
+ |
} |
| 173 |
|
|
| 174 |
|
int |
| 175 |
|
closestapproach( /* closest approach of two rays */ |