3 * Routines to convert between geodetic and geocentric coordinate systems.
4 * Copied and adapted directly from LaRCsim/ls_geodesy.c
7 // See below for the complete original LaRCsim comments.
12 #ifndef _SG_GEODESY_HXX
13 #define _SG_GEODESY_HXX
17 # error This library requires C++
21 #include <simgear/math/point3d.hxx>
22 #include <simgear/math/polar3d.hxx>
26 * Convert from geocentric coordinates to geodetic coordinates
27 * @param lat_geoc (in) Geocentric latitude, radians, + = North
28 * @param radius (in) C.G. radius to earth center (meters)
29 * @param lat_geod (out) Geodetic latitude, radians, + = North
30 * @param alt (out) C.G. altitude above mean sea level (meters)
31 * @param sea_level_r (out) radius from earth center to sea level at
32 * local vertical (surface normal) of C.G. (meters)
34 void sgGeocToGeod( const double& lat_geoc, const double& radius,
35 double *lat_geod, double *alt, double *sea_level_r );
39 * Convert from geodetic coordinates to geocentric coordinates
40 * @param lat_geod (in) Geodetic latitude, radians, + = North
41 * @param alt (in) C.G. altitude above mean sea level (meters)
42 * @param sl_radius (out) SEA LEVEL radius to earth center (meters)
43 * (add Altitude to get true distance from earth center.
44 * @param lat_geoc (out) Geocentric latitude, radians, + = North
46 void sgGeodToGeoc( const double& lat_geod, const double& alt,
47 double *sl_radius, double *lat_geoc );
51 * Convert a geodetic point lon(radians), lat(radians), elev(meter) to
53 * @param geodetic point
54 * @return cartesian point
56 inline Point3D sgGeodToCart(const Point3D& geod) {
57 double gc_lon, gc_lat, sl_radius;
59 // printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
60 // geod[0], geod[1], geod[2]);
63 sgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
65 // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
66 // gc_lat, sl_radius+geod[2]);
68 Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius());
69 return sgPolarToCart3d(pp);
74 * Given a starting position and an offset radial and distance,
75 * calculate an ending positon on a wgs84 ellipsoid.
76 * @param alt (in) meters
77 * @param lat1 (in) degrees
78 * @param lon1 (in) degrees
79 * @param az1 (in) degrees
80 * @param s (in) distance in meters
81 * @param lat2 (out) degrees
82 * @param lon2 (out) degrees
83 * @param az2 (out) return course in degrees
85 int geo_direct_wgs_84 ( const double& alt, const double& lat1,
86 const double& lon1, const double& az1,
87 const double& s, double *lat2, double *lon2,
92 * Given an altitude and two sets of (lat, lon) calculate great circle
93 * distance between them as well as the starting and ending azimuths.
94 * @param alt (in) meters
95 * @param lat1 (in) degrees
96 * @param lon1 (in) degrees
97 * @param lat2 (in) degrees
98 * @param lon2 (in) degrees
99 * @param az1 (out) start heading degrees
100 * @param az2 (out) end heading degrees
101 * @param s (out) distance meters
103 int geo_inverse_wgs_84( const double& alt, const double& lat1,
104 const double& lon1, const double& lat2,
105 const double& lon2, double *az1, double *az2,
109 /***************************************************************************
113 ----------------------------------------------------------------------------
115 FUNCTION: Converts geocentric coordinates to geodetic positions
117 ----------------------------------------------------------------------------
119 MODULE STATUS: developmental
121 ----------------------------------------------------------------------------
123 GENEALOGY: Written as part of LaRCSim project by E. B. Jackson
125 ----------------------------------------------------------------------------
127 DESIGNED BY: E. B. Jackson
129 CODED BY: E. B. Jackson
131 MAINTAINED BY: E. B. Jackson
133 ----------------------------------------------------------------------------
135 MODIFICATION HISTORY:
139 930208 Modified to avoid singularity near polar region. EBJ
140 930602 Moved backwards calcs here from ls_step. EBJ
141 931214 Changed erroneous Latitude and Altitude variables to
142 *lat_geod and *alt in routine ls_geoc_to_geod. EBJ
143 940111 Changed header files from old ls_eom.h style to ls_types,
144 and ls_constants. Also replaced old DATA type with new
151 * Revision 1.5 1994/01/11 18:47:05 bjax
152 * Changed include files to use types and constants, not ls_eom.h
153 * Also changed DATA type to SCALAR type.
155 * Revision 1.4 1993/12/14 21:06:47 bjax
156 * Removed global variable references Altitude and Latitude. EBJ
158 * Revision 1.3 1993/06/02 15:03:40 bjax
159 * Made new subroutine for calculating geodetic to geocentric; changed name
160 * of forward conversion routine from ls_geodesy to ls_geoc_to_geod.
163 ----------------------------------------------------------------------------
167 [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft
168 Control and Simulation", Wiley and Sons, 1992.
172 ----------------------------------------------------------------------------
176 ----------------------------------------------------------------------------
180 ----------------------------------------------------------------------------
183 lat_geoc Geocentric latitude, radians, + = North
184 radius C.G. radius to earth center, ft
186 ----------------------------------------------------------------------------
189 lat_geod Geodetic latitude, radians, + = North
190 alt C.G. altitude above mean sea level, ft
191 sea_level_r radius from earth center to sea level at
192 local vertical (surface normal) of C.G.
194 --------------------------------------------------------------------------*/
197 #endif // _SG_GEODESY_HXX