1 // fg_geodesy.hxx -- routines to convert between geodetic and geocentric
4 // Copied and adapted directly from LaRCsim/ls_geodesy.c
6 // See below for the complete original LaRCsim comments.
11 #ifndef _FG_GEODESY_HXX
12 #define _FG_GEODESY_HXX
16 # error This library requires C++
20 #include <simgear/math/point3d.hxx>
21 #include <simgear/math/polar3d.hxx>
24 // fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
26 // lat_geoc Geocentric latitude, radians, + = North
27 // radius C.G. radius to earth center (meters)
30 // lat_geod Geodetic latitude, radians, + = North
31 // alt C.G. altitude above mean sea level (meters)
32 // sea_level_r radius from earth center to sea level at
33 // local vertical (surface normal) of C.G. (meters)
35 void fgGeocToGeod( double lat_geoc, double radius, double
36 *lat_geod, double *alt, double *sea_level_r );
39 // fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
41 // lat_geod Geodetic latitude, radians, + = North
42 // alt C.G. altitude above mean sea level (meters)
45 // sl_radius SEA LEVEL radius to earth center (meters)
46 // (add Altitude to get true distance from earth center.
47 // lat_geoc Geocentric latitude, radians, + = North
50 void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
54 // convert a geodetic point lon(radians), lat(radians), elev(meter) to
57 inline Point3D fgGeodToCart(const Point3D& geod) {
58 double gc_lon, gc_lat, sl_radius;
60 // printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
61 // geod[0], geod[1], geod[2]);
64 fgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
66 // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
67 // gc_lat, sl_radius+geod[2]);
69 Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius());
70 return fgPolarToCart3d(pp);
74 // given, alt, lat1, lon1, az1 and distance (s), calculate lat2, lon2
75 // and az2. Lat, lon, and azimuth are in degrees. distance in meters
76 int geo_direct_wgs_84 ( double alt, double lat1, double lon1, double az1,
77 double s, double *lat2, double *lon2, double *az2 );
80 // given alt, lat1, lon1, lat2, lon2, calculate starting and ending
81 // az1, az2 and distance (s). Lat, lon, and azimuth are in degrees.
83 int geo_inverse_wgs_84( double alt, double lat1, double lon1, double lat2,
84 double lon2, double *az1, double *az2, double *s );
87 /***************************************************************************
91 ----------------------------------------------------------------------------
93 FUNCTION: Converts geocentric coordinates to geodetic positions
95 ----------------------------------------------------------------------------
97 MODULE STATUS: developmental
99 ----------------------------------------------------------------------------
101 GENEALOGY: Written as part of LaRCSim project by E. B. Jackson
103 ----------------------------------------------------------------------------
105 DESIGNED BY: E. B. Jackson
107 CODED BY: E. B. Jackson
109 MAINTAINED BY: E. B. Jackson
111 ----------------------------------------------------------------------------
113 MODIFICATION HISTORY:
117 930208 Modified to avoid singularity near polar region. EBJ
118 930602 Moved backwards calcs here from ls_step. EBJ
119 931214 Changed erroneous Latitude and Altitude variables to
120 *lat_geod and *alt in routine ls_geoc_to_geod. EBJ
121 940111 Changed header files from old ls_eom.h style to ls_types,
122 and ls_constants. Also replaced old DATA type with new
129 * Revision 1.5 1994/01/11 18:47:05 bjax
130 * Changed include files to use types and constants, not ls_eom.h
131 * Also changed DATA type to SCALAR type.
133 * Revision 1.4 1993/12/14 21:06:47 bjax
134 * Removed global variable references Altitude and Latitude. EBJ
136 * Revision 1.3 1993/06/02 15:03:40 bjax
137 * Made new subroutine for calculating geodetic to geocentric; changed name
138 * of forward conversion routine from ls_geodesy to ls_geoc_to_geod.
141 ----------------------------------------------------------------------------
145 [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft
146 Control and Simulation", Wiley and Sons, 1992.
150 ----------------------------------------------------------------------------
154 ----------------------------------------------------------------------------
158 ----------------------------------------------------------------------------
161 lat_geoc Geocentric latitude, radians, + = North
162 radius C.G. radius to earth center, ft
164 ----------------------------------------------------------------------------
167 lat_geod Geodetic latitude, radians, + = North
168 alt C.G. altitude above mean sea level, ft
169 sea_level_r radius from earth center to sea level at
170 local vertical (surface normal) of C.G.
172 --------------------------------------------------------------------------*/
175 #endif // _FG_GEODESY_HXX