| 13 |
|
|
| 14 |
|
double |
| 15 |
|
fdot( /* return the dot product of two vectors */ |
| 16 |
< |
FVECT v1, |
| 17 |
< |
FVECT v2 |
| 16 |
> |
const FVECT v1, |
| 17 |
> |
const FVECT v2 |
| 18 |
|
) |
| 19 |
|
{ |
| 20 |
|
return(DOT(v1,v2)); |
| 23 |
|
|
| 24 |
|
double |
| 25 |
|
dist2( /* return square of distance between points */ |
| 26 |
< |
FVECT p1, |
| 27 |
< |
FVECT p2 |
| 26 |
> |
const FVECT p1, |
| 27 |
> |
const FVECT p2 |
| 28 |
|
) |
| 29 |
|
{ |
| 30 |
|
FVECT delta; |
| 39 |
|
|
| 40 |
|
double |
| 41 |
|
dist2line( /* return square of distance to line */ |
| 42 |
< |
FVECT p, /* the point */ |
| 43 |
< |
FVECT ep1, |
| 44 |
< |
FVECT ep2 /* points on the line */ |
| 42 |
> |
const FVECT p, /* the point */ |
| 43 |
> |
const FVECT ep1, |
| 44 |
> |
const FVECT ep2 /* points on the line */ |
| 45 |
|
) |
| 46 |
|
{ |
| 47 |
|
double d, d1, d2; |
| 56 |
|
|
| 57 |
|
double |
| 58 |
|
dist2lseg( /* return square of distance to line segment */ |
| 59 |
< |
FVECT p, /* the point */ |
| 60 |
< |
FVECT ep1, |
| 61 |
< |
FVECT ep2 /* the end points */ |
| 59 |
> |
const FVECT p, /* the point */ |
| 60 |
> |
const FVECT ep1, |
| 61 |
> |
const FVECT ep2 /* the end points */ |
| 62 |
|
) |
| 63 |
|
{ |
| 64 |
|
double d, d1, d2; |
| 83 |
|
void |
| 84 |
|
fcross( /* vres = v1 X v2 */ |
| 85 |
|
FVECT vres, |
| 86 |
< |
FVECT v1, |
| 87 |
< |
FVECT v2 |
| 86 |
> |
const FVECT v1, |
| 87 |
> |
const FVECT v2 |
| 88 |
|
) |
| 89 |
|
{ |
| 90 |
|
vres[0] = v1[1]*v2[2] - v1[2]*v2[1]; |
| 96 |
|
void |
| 97 |
|
fvsum( /* vres = v0 + f*v1 */ |
| 98 |
|
FVECT vres, |
| 99 |
< |
FVECT v0, |
| 100 |
< |
FVECT v1, |
| 99 |
> |
const FVECT v0, |
| 100 |
> |
const FVECT v1, |
| 101 |
|
double f |
| 102 |
|
) |
| 103 |
|
{ |
| 137 |
|
int |
| 138 |
|
closestapproach( /* closest approach of two rays */ |
| 139 |
|
RREAL t[2], /* returned distances along each ray */ |
| 140 |
< |
FVECT rorg0, /* first origin */ |
| 141 |
< |
FVECT rdir0, /* first direction (normalized) */ |
| 142 |
< |
FVECT rorg1, /* second origin */ |
| 143 |
< |
FVECT rdir1 /* second direction (normalized) */ |
| 140 |
> |
const FVECT rorg0, /* first origin */ |
| 141 |
> |
const FVECT rdir0, /* first direction (normalized) */ |
| 142 |
> |
const FVECT rorg1, /* second origin */ |
| 143 |
> |
const FVECT rdir1 /* second direction (normalized) */ |
| 144 |
|
) |
| 145 |
|
{ |
| 146 |
|
double dotprod = DOT(rdir0, rdir1); |
| 163 |
|
void |
| 164 |
|
spinvector( /* rotate vector around normal */ |
| 165 |
|
FVECT vres, /* returned vector */ |
| 166 |
< |
FVECT vorig, /* original vector */ |
| 167 |
< |
FVECT vnorm, /* normalized vector for rotation */ |
| 166 |
> |
const FVECT vorig, /* original vector */ |
| 167 |
> |
const FVECT vnorm, /* normalized vector for rotation */ |
| 168 |
|
double theta /* left-hand radians */ |
| 169 |
|
) |
| 170 |
|
{ |