2 * Copyright (C) 2009 Andy Spencer <spenceal@rose-hulman.edu>
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
27 void lle2xyz(gdouble lat, gdouble lon, gdouble elev,
28 gdouble *x, gdouble *y, gdouble *z)
30 gdouble rad = elev2rad(elev);
31 gdouble azim = lon2azim(lon);
32 gdouble incl = lat2incl(lat);
33 *z = rad * cos(azim) * sin(incl);
34 *x = rad * sin(azim) * sin(incl);
38 void xyz2lle(gdouble x, gdouble y, gdouble z,
39 gdouble *lat, gdouble *lon, gdouble *elev)
41 gdouble rad = sqrt(x*x + y*y + z*z);
42 *lat = incl2lat(acos(y / rad));
43 *lon = azim2lon(atan2(x,z));
44 *elev = rad2elev(rad);
47 void xyz2ll(gdouble x, gdouble y, gdouble z,
48 gdouble *lat, gdouble *lon)
50 gdouble rad = sqrt(x*x + y*y + z*z);
51 *lat = incl2lat(acos(y / rad));
52 *lon = azim2lon(atan2(x,z));
55 gdouble ll2m(gdouble lon_dist, gdouble lat)
57 gdouble azim = (-lat+90)/180*M_PI;
58 gdouble rad = sin(azim) * EARTH_R;
59 gdouble circ = 2 * M_PI * rad;
60 return lon_dist/360 * circ;
63 gdouble distd(gdouble *a, gdouble *b)
65 return sqrt((a[0]-b[0])*(a[0]-b[0]) +
66 (a[1]-b[1])*(a[1]-b[1]) +
67 (a[2]-b[2])*(a[2]-b[2]));