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 <Math/point3d.hxx>
21 #include <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 /***************************************************************************
78 ----------------------------------------------------------------------------
80 FUNCTION: Converts geocentric coordinates to geodetic positions
82 ----------------------------------------------------------------------------
84 MODULE STATUS: developmental
86 ----------------------------------------------------------------------------
88 GENEALOGY: Written as part of LaRCSim project by E. B. Jackson
90 ----------------------------------------------------------------------------
92 DESIGNED BY: E. B. Jackson
94 CODED BY: E. B. Jackson
96 MAINTAINED BY: E. B. Jackson
98 ----------------------------------------------------------------------------
100 MODIFICATION HISTORY:
104 930208 Modified to avoid singularity near polar region. EBJ
105 930602 Moved backwards calcs here from ls_step. EBJ
106 931214 Changed erroneous Latitude and Altitude variables to
107 *lat_geod and *alt in routine ls_geoc_to_geod. EBJ
108 940111 Changed header files from old ls_eom.h style to ls_types,
109 and ls_constants. Also replaced old DATA type with new
116 * Revision 1.5 1994/01/11 18:47:05 bjax
117 * Changed include files to use types and constants, not ls_eom.h
118 * Also changed DATA type to SCALAR type.
120 * Revision 1.4 1993/12/14 21:06:47 bjax
121 * Removed global variable references Altitude and Latitude. EBJ
123 * Revision 1.3 1993/06/02 15:03:40 bjax
124 * Made new subroutine for calculating geodetic to geocentric; changed name
125 * of forward conversion routine from ls_geodesy to ls_geoc_to_geod.
128 ----------------------------------------------------------------------------
132 [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft
133 Control and Simulation", Wiley and Sons, 1992.
137 ----------------------------------------------------------------------------
141 ----------------------------------------------------------------------------
145 ----------------------------------------------------------------------------
148 lat_geoc Geocentric latitude, radians, + = North
149 radius C.G. radius to earth center, ft
151 ----------------------------------------------------------------------------
154 lat_geod Geodetic latitude, radians, + = North
155 alt C.G. altitude above mean sea level, ft
156 sea_level_r radius from earth center to sea level at
157 local vertical (surface normal) of C.G.
159 --------------------------------------------------------------------------*/
162 #endif // _FG_GEODESY_HXX