]> git.mxchange.org Git - simgear.git/blob - Lib/Math/fg_geodesy.hxx
Fixed an IRIX warning message where an inline function is referenced
[simgear.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
10
11 #ifndef _FG_GEODESY_HXX
12 #define _FG_GEODESY_HXX
13
14
15 #ifndef __cplusplus                                                          
16 # error This library requires C++
17 #endif                                   
18
19
20 #include <Math/point3d.hxx>
21 #include <Math/polar3d.hxx>
22
23
24 // fgGeocToGeod(lat_geoc, radius, *lat_geod, *alt, *sea_level_r)
25 //     INPUTS:  
26 //         lat_geoc     Geocentric latitude, radians, + = North
27 //         radius       C.G. radius to earth center (meters)
28 //
29 //     OUTPUTS:
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)
34
35 void fgGeocToGeod( double lat_geoc, double radius, double
36                    *lat_geod, double *alt, double *sea_level_r );
37
38
39 // fgGeodToGeoc( lat_geod, alt, *sl_radius, *lat_geoc )
40 //     INPUTS:  
41 //         lat_geod     Geodetic latitude, radians, + = North
42 //         alt          C.G. altitude above mean sea level (meters)
43 //
44 //     OUTPUTS:
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
48 //
49
50 void fgGeodToGeoc( double lat_geod, double alt, double *sl_radius,
51                       double *lat_geoc );
52
53
54 // convert a geodetic point lon(radians), lat(radians), elev(meter) to
55 // a cartesian point
56
57 inline Point3D fgGeodToCart(const Point3D& geod) {
58     double gc_lon, gc_lat, sl_radius;
59
60     // printf("A geodetic point is (%.2f, %.2f, %.2f)\n", 
61     //        geod[0], geod[1], geod[2]);
62
63     gc_lon = geod.lon();
64     fgGeodToGeoc(geod.lat(), geod.radius(), &sl_radius, &gc_lat);
65
66     // printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, 
67     //        gc_lat, sl_radius+geod[2]);
68
69     Point3D pp = Point3D( gc_lon, gc_lat, sl_radius + geod.radius());
70     return fgPolarToCart3d(pp);
71 }
72
73
74 /***************************************************************************
75
76         TITLE:  ls_geodesy
77         
78 ----------------------------------------------------------------------------
79
80         FUNCTION:       Converts geocentric coordinates to geodetic positions
81
82 ----------------------------------------------------------------------------
83
84         MODULE STATUS:  developmental
85
86 ----------------------------------------------------------------------------
87
88         GENEALOGY:      Written as part of LaRCSim project by E. B. Jackson
89
90 ----------------------------------------------------------------------------
91
92         DESIGNED BY:    E. B. Jackson
93         
94         CODED BY:       E. B. Jackson
95         
96         MAINTAINED BY:  E. B. Jackson
97
98 ----------------------------------------------------------------------------
99
100         MODIFICATION HISTORY:
101         
102         DATE    PURPOSE                                         BY
103         
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
110                 SCALAR type.                                            EBJ
111
112         CURRENT RCS HEADER:
113
114 $Header$
115
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.
119  *
120  * Revision 1.4  1993/12/14  21:06:47  bjax
121  * Removed global variable references Altitude and Latitude.   EBJ
122  *
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.
126  *
127
128 ----------------------------------------------------------------------------
129
130         REFERENCES:
131
132                 [ 1]    Stevens, Brian L.; and Lewis, Frank L.: "Aircraft 
133                         Control and Simulation", Wiley and Sons, 1992.
134                         ISBN 0-471-61397-5                    
135
136
137 ----------------------------------------------------------------------------
138
139         CALLED BY:      ls_aux
140
141 ----------------------------------------------------------------------------
142
143         CALLS TO:
144
145 ----------------------------------------------------------------------------
146
147         INPUTS: 
148                 lat_geoc        Geocentric latitude, radians, + = North
149                 radius          C.G. radius to earth center, ft
150
151 ----------------------------------------------------------------------------
152
153         OUTPUTS:
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.
158
159 --------------------------------------------------------------------------*/
160
161
162 #endif // _FG_GEODESY_HXX