2 |
|
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
4 |
|
/* |
5 |
< |
* Compute 4-byte direction code (assume this fits into int) |
5 |
> |
* Compute a 4-byte direction code (int32 type defined in standard.h). |
6 |
> |
* |
7 |
> |
* Mean accuracy is 0.0022 degrees, with a maximum error of 0.0058 degrees. |
8 |
|
*/ |
9 |
|
|
10 |
|
#include "standard.h" |
19 |
|
#define F2SFT 18 |
20 |
|
#define FMASK 0x1fff |
21 |
|
|
22 |
< |
int4 |
22 |
> |
int32 |
23 |
|
encodedir(dv) /* encode a normalized direction vector */ |
24 |
|
FVECT dv; |
25 |
|
{ |
26 |
< |
register int4 dc = 0; |
26 |
> |
register int32 dc = 0; |
27 |
|
int cd[3], cm; |
28 |
|
register int i; |
29 |
|
|
30 |
|
for (i = 0; i < 3; i++) |
31 |
|
if (dv[i] < 0.) { |
32 |
< |
cd[i] = dv[i] * -DCSCALE; |
32 |
> |
cd[i] = (int)(dv[i] * -DCSCALE); |
33 |
|
dc |= FXNEG<<i; |
34 |
|
} else |
35 |
< |
cd[i] = dv[i] * DCSCALE; |
35 |
> |
cd[i] = (int)(dv[i] * DCSCALE); |
36 |
|
if (cd[0] <= cd[1]) { |
37 |
|
dc |= F1X | cd[0] << F1SFT; |
38 |
|
cm = cd[1]; |
53 |
|
void |
54 |
|
decodedir(dv, dc) /* decode a normalized direction vector */ |
55 |
|
register FVECT dv; /* returned */ |
56 |
< |
register int4 dc; |
56 |
> |
register int32 dc; |
57 |
|
{ |
58 |
|
double d1, d2, der; |
59 |
|
|
77 |
|
|
78 |
|
double |
79 |
|
dir2diff(dc1, dc2) /* approx. radians^2 between directions */ |
80 |
< |
int4 dc1, dc2; |
80 |
> |
int32 dc1, dc2; |
81 |
|
{ |
82 |
|
FVECT v1, v2; |
83 |
|
|
90 |
|
|
91 |
|
double |
92 |
|
fdir2diff(dc1, v2) /* approx. radians^2 between directions */ |
93 |
< |
int4 dc1; |
93 |
> |
int32 dc1; |
94 |
|
register FVECT v2; |
95 |
|
{ |
96 |
|
FVECT v1; |