4 void geo2space(double *x
, double *y
, double *z
, double lon
, double lat
)
6 *z
= sin(lat
/ 180.0 * PI
) * POLE_RADIUS
;
7 *x
= sin(lon
/ 180.0 * PI
) * cos(lat
/ 180.0 * PI
) * EQUATOR_RADIUS
;
8 *y
= -cos(lon
/ 180.0 * PI
) * cos(lat
/ 180.0 * PI
) * EQUATOR_RADIUS
;
11 void space2geo(double *lon
, double *lat
, double x
, double y
, double z
)
15 /* bring geoid to 1m radius */
17 x
= x
/ EQUATOR_RADIUS
;
18 y
= y
/ EQUATOR_RADIUS
;
21 r
= sqrt(x
* x
+ y
* y
+ z
* z
);
26 *lat
= asin(z
) / PI
* 180;
27 *lon
= atan2(x
, -y
) / PI
* 180;
30 double distinspace(double x1
, double y1
, double z1
, double x2
, double y2
,
37 return sqrt(x
* x
+ y
* y
+ z
* z
);
40 double distonplane(double x1
, double y1
, double x2
, double y2
)
45 return sqrt(x
* x
+ y
* y
);