]> git.mxchange.org Git - flightgear.git/blob - Lib/Math/fg_geodesy.hxx
Merge FG_Lib as subdirectory
[flightgear.git] / Lib / Math / fg_geodesy.hxx
1 // fg_geodesy.hxx -- routines to convert between geodetic and geocentric 
2 //                   coordinate systems.
3 //
4 // Copied and adapted directly from LaRCsim/ls_geodesy.c
5 //
6 // See below for the complete original LaRCsim comments.
7 //
8 // $Id$
9 // (Log is kept at end of this file)
10
11
12 #ifndef _FG_GEODESY_HXX
13 #define _FG_GEODESY_HXX
14
15
16 #ifndef __cplusplus                                                          
17 # error This library requires C++
18 #endif                                   
19
20
21 #include <Math/point3d.hxx>
22 #include <Math/polar3d.hxx>
23
24
25 // fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
26 //     INPUTS:  
27 //         lat_geoc     Geocentric latitude, radians, + = North
28 //         radius       C.G. radius to earth center (meters)
29 //
30 //     OUTPUTS:
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)
35
36 void fgGeocToGeod( double lat_geoc, double radius, double
37                    *lat_geod, double *alt, double *sea_level_r );
38
39
40 // fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
41 //     INPUTS:  
42 //         lat_geod     Geodetic latitude, radians, + = North
43 //         alt          C.G. altitude above mean sea level (meters)
44 //
45 //     OUTPUTS:
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
49 //
50
51 void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
52                       double *lat_geoc );
53
54
55 // convert a geodetic point lon(radians), lat(radians), elev(meter) to
56 // a cartesian point
57
58 inline Point3D fgGeodToCart(const Point3D& geod) {
59     double gc_lon, gc_lat, sl_radius;
60
61     // printf("A geodetic point is (%.2f, %.2f, %.2f)\n", 
62     //        geod[0], geod[1], geod[2]);
63
64     gc_lon = geod.lon();
65     fgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
66
67     // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, 
68     //        gc_lat, sl_radius+geod[2]);
69
70     Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius());
71     return fgPolarToCart3d(pp);
72 }
73
74
75 /***************************************************************************
76
77         TITLE:  ls_geodesy
78         
79 ----------------------------------------------------------------------------
80
81         FUNCTION:       Converts geocentric coordinates to geodetic positions
82
83 ----------------------------------------------------------------------------
84
85         MODULE STATUS:  developmental
86
87 ----------------------------------------------------------------------------
88
89         GENEALOGY:      Written as part of LaRCSim project by E. B. Jackson
90
91 ----------------------------------------------------------------------------
92
93         DESIGNED BY:    E. B. Jackson
94         
95         CODED BY:       E. B. Jackson
96         
97         MAINTAINED BY:  E. B. Jackson
98
99 ----------------------------------------------------------------------------
100
101         MODIFICATION HISTORY:
102         
103         DATE    PURPOSE                                         BY
104         
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
111                 SCALAR type.                                            EBJ
112
113         CURRENT RCS HEADER:
114
115 $Header$
116 $Log$
117 Revision 1.4  1999/01/27 04:46:15  curt
118 Portability tweaks by Bernie Bright.
119
120 Revision 1.3  1998/10/18 01:17:11  curt
121 Point3D tweaks.
122
123 Revision 1.2  1998/10/16 23:36:37  curt
124 c++-ifying.
125
126 Revision 1.1  1998/10/16 19:30:42  curt
127 Renamed .c -> .h so we can start adding c++ supporting routines.
128
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
132   meters.
133
134 Revision 1.3  1998/04/21 17:03:48  curt
135 Prepairing for C++ integration.
136
137 Revision 1.2  1998/01/22 02:59:38  curt
138 Changed #ifdef FILE_H to #ifdef _FILE_H
139
140 Revision 1.1  1997/07/31 23:13:14  curt
141 Initial revision.
142
143 Revision 1.1  1997/05/29 00:09:56  curt
144 Initial Flight Gear revision.
145
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.
149  *
150  * Revision 1.4  1993/12/14  21:06:47  bjax
151  * Removed global variable references Altitude and Latitude.   EBJ
152  *
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.
156  *
157
158 ----------------------------------------------------------------------------
159
160         REFERENCES:
161
162                 [ 1]    Stevens, Brian L.; and Lewis, Frank L.: "Aircraft 
163                         Control and Simulation", Wiley and Sons, 1992.
164                         ISBN 0-471-61397-5                    
165
166
167 ----------------------------------------------------------------------------
168
169         CALLED BY:      ls_aux
170
171 ----------------------------------------------------------------------------
172
173         CALLS TO:
174
175 ----------------------------------------------------------------------------
176
177         INPUTS: 
178                 lat_geoc        Geocentric latitude, radians, + = North
179                 radius          C.G. radius to earth center, ft
180
181 ----------------------------------------------------------------------------
182
183         OUTPUTS:
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.
188
189 --------------------------------------------------------------------------*/
190
191
192 #endif // _FG_GEODESY_HXX
193
194
195 // $Log$
196 // Revision 1.4  1999/01/27 04:46:15  curt
197 // Portability tweaks by Bernie Bright.
198 //
199 // Revision 1.3  1998/10/18 01:17:11  curt
200 // Point3D tweaks.
201 //
202 // Revision 1.2  1998/10/16 23:36:37  curt
203 // c++-ifying.
204 //
205 // Revision 1.1  1998/10/16 19:30:42  curt
206 // Renamed .c -> .h so we can start adding c++ supporting routines.
207 //
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
211 //   meters.
212 //
213 // Revision 1.3  1998/04/21 17:03:48  curt
214 // Prepairing for C++ integration.
215 //
216 // Revision 1.2  1998/01/22 02:59:38  curt
217 // Changed #ifdef FILE_H to #ifdef _FILE_H
218 //
219 // Revision 1.1  1997/07/31 23:13:14  curt
220 // Initial revision.
221 //
222