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.
9 // (Log is kept at end of this file)
12 #ifndef _FG_GEODESY_HXX
13 #define _FG_GEODESY_HXX
17 # error This library requires C++
21 #include <Math/point3d.hxx>
22 #include <Math/polar3d.hxx>
25 // fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
27 // lat_geoc Geocentric latitude, radians, + = North
28 // radius C.G. radius to earth center (meters)
31 // lat_geod Geodetic latitude, radians, + = North
32 // alt C.G. altitude above mean sea level (meters)
33 // sea_level_r radius from earth center to sea level at
34 // local vertical (surface normal) of C.G. (meters)
36 void fgGeocToGeod( double lat_geoc, double radius, double
37 *lat_geod, double *alt, double *sea_level_r );
40 // fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
42 // lat_geod Geodetic latitude, radians, + = North
43 // alt C.G. altitude above mean sea level (meters)
46 // sl_radius SEA LEVEL radius to earth center (meters)
47 // (add Altitude to get true distance from earth center.
48 // lat_geoc Geocentric latitude, radians, + = North
51 void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
55 // convert a geodetic point lon(radians), lat(radians), elev(meter) to
58 inline Point3D fgGeodToCart(const Point3D& geod) {
61 double gc_lon, gc_lat, sl_radius;
63 // printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
64 // geod[0], geod[1], geod[2]);
67 fgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
69 // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
70 // gc_lat, sl_radius+geod[2]);
72 pp.setvals(gc_lon, gc_lat, sl_radius + geod.radius());
73 cp = fgPolarToCart3d(pp);
75 // printf("A cart point is (%.8f, %.8f, %.8f)\n", cp.x, cp.y, cp.z);
81 /***************************************************************************
85 ----------------------------------------------------------------------------
87 FUNCTION: Converts geocentric coordinates to geodetic positions
89 ----------------------------------------------------------------------------
91 MODULE STATUS: developmental
93 ----------------------------------------------------------------------------
95 GENEALOGY: Written as part of LaRCSim project by E. B. Jackson
97 ----------------------------------------------------------------------------
99 DESIGNED BY: E. B. Jackson
101 CODED BY: E. B. Jackson
103 MAINTAINED BY: E. B. Jackson
105 ----------------------------------------------------------------------------
107 MODIFICATION HISTORY:
111 930208 Modified to avoid singularity near polar region. EBJ
112 930602 Moved backwards calcs here from ls_step. EBJ
113 931214 Changed erroneous Latitude and Altitude variables to
114 *lat_geod and *alt in routine ls_geoc_to_geod. EBJ
115 940111 Changed header files from old ls_eom.h style to ls_types,
116 and ls_constants. Also replaced old DATA type with new
123 Revision 1.2 1998/10/16 23:36:37 curt
126 Revision 1.1 1998/10/16 19:30:42 curt
127 Renamed .c -> .h so we can start adding c++ supporting routines.
129 Revision 1.4 1998/07/08 14:40:08 curt
130 polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
131 Updated fg_geodesy comments to reflect that routines expect and produce
134 Revision 1.3 1998/04/21 17:03:48 curt
135 Prepairing for C++ integration.
137 Revision 1.2 1998/01/22 02:59:38 curt
138 Changed #ifdef FILE_H to #ifdef _FILE_H
140 Revision 1.1 1997/07/31 23:13:14 curt
143 Revision 1.1 1997/05/29 00:09:56 curt
144 Initial Flight Gear revision.
146 * Revision 1.5 1994/01/11 18:47:05 bjax
147 * Changed include files to use types and constants, not ls_eom.h
148 * Also changed DATA type to SCALAR type.
150 * Revision 1.4 1993/12/14 21:06:47 bjax
151 * Removed global variable references Altitude and Latitude. EBJ
153 * Revision 1.3 1993/06/02 15:03:40 bjax
154 * Made new subroutine for calculating geodetic to geocentric; changed name
155 * of forward conversion routine from ls_geodesy to ls_geoc_to_geod.
158 ----------------------------------------------------------------------------
162 [ 1] Stevens, Brian L.; and Lewis, Frank L.: "Aircraft
163 Control and Simulation", Wiley and Sons, 1992.
167 ----------------------------------------------------------------------------
171 ----------------------------------------------------------------------------
175 ----------------------------------------------------------------------------
178 lat_geoc Geocentric latitude, radians, + = North
179 radius C.G. radius to earth center, ft
181 ----------------------------------------------------------------------------
184 lat_geod Geodetic latitude, radians, + = North
185 alt C.G. altitude above mean sea level, ft
186 sea_level_r radius from earth center to sea level at
187 local vertical (surface normal) of C.G.
189 --------------------------------------------------------------------------*/
192 #endif // _FG_GEODESY_HXX
196 // Revision 1.2 1998/10/16 23:36:37 curt
199 // Revision 1.1 1998/10/16 19:30:42 curt
200 // Renamed .c -> .h so we can start adding c++ supporting routines.
202 // Revision 1.4 1998/07/08 14:40:08 curt
203 // polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
204 // Updated fg_geodesy comments to reflect that routines expect and produce
207 // Revision 1.3 1998/04/21 17:03:48 curt
208 // Prepairing for C++ integration.
210 // Revision 1.2 1998/01/22 02:59:38 curt
211 // Changed #ifdef FILE_H to #ifdef _FILE_H
213 // Revision 1.1 1997/07/31 23:13:14 curt