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) {
59 double gc_lon, gc_lat, sl_radius;
61 // printf("A geodetic point is (%.2f, %.2f, %.2f)\n",
62 // geod[0], geod[1], geod[2]);
65 fgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
67 // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon,
68 // gc_lat, sl_radius+geod[2]);
70 Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius());
71 return fgPolarToCart3d(pp);
75 /***************************************************************************
79 ----------------------------------------------------------------------------
81 FUNCTION: Converts geocentric coordinates to geodetic positions
83 ----------------------------------------------------------------------------
85 MODULE STATUS: developmental
87 ----------------------------------------------------------------------------
89 GENEALOGY: Written as part of LaRCSim project by E. B. Jackson
91 ----------------------------------------------------------------------------
93 DESIGNED BY: E. B. Jackson
95 CODED BY: E. B. Jackson
97 MAINTAINED BY: E. B. Jackson
99 ----------------------------------------------------------------------------
101 MODIFICATION HISTORY:
105 930208 Modified to avoid singularity near polar region. EBJ
106 930602 Moved backwards calcs here from ls_step. EBJ
107 931214 Changed erroneous Latitude and Altitude variables to
108 *lat_geod and *alt in routine ls_geoc_to_geod. EBJ
109 940111 Changed header files from old ls_eom.h style to ls_types,
110 and ls_constants. Also replaced old DATA type with new
117 Revision 1.4 1999/01/27 04:46:15 curt
118 Portability tweaks by Bernie Bright.
120 Revision 1.3 1998/10/18 01:17:11 curt
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.4 1999/01/27 04:46:15 curt
197 // Portability tweaks by Bernie Bright.
199 // Revision 1.3 1998/10/18 01:17:11 curt
202 // Revision 1.2 1998/10/16 23:36:37 curt
205 // Revision 1.1 1998/10/16 19:30:42 curt
206 // Renamed .c -> .h so we can start adding c++ supporting routines.
208 // Revision 1.4 1998/07/08 14:40:08 curt
209 // polar3d.[ch] renamed to polar3d.[ch]xx, vector.[ch] renamed to vector.[ch]xx
210 // Updated fg_geodesy comments to reflect that routines expect and produce
213 // Revision 1.3 1998/04/21 17:03:48 curt
214 // Prepairing for C++ integration.
216 // Revision 1.2 1998/01/22 02:59:38 curt
217 // Changed #ifdef FILE_H to #ifdef _FILE_H
219 // Revision 1.1 1997/07/31 23:13:14 curt