File: NormalGravity.h

package info (click to toggle)
geographiclib 1.37-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 9,688 kB
  • ctags: 4,871
  • sloc: cpp: 31,440; sh: 11,632; cs: 9,411; ansic: 1,428; java: 1,333; python: 1,131; makefile: 758; xml: 381; pascal: 30
file content (361 lines) | stat: -rw-r--r-- 17,418 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
#pragma once
/**
 * \file NETGeographicLib/NormalGravity.h
 * \brief Header for NETGeographicLib::NormalGravity class
 *
 * NETGeographicLib is copyright (c) Scott Heiman (2013)
 * GeographicLib is Copyright (c) Charles Karney (2010-2012)
 * <charles@karney.com> and licensed under the MIT/X11 License.
 * For more information, see
 * http://geographiclib.sourceforge.net/
 **********************************************************************/

namespace NETGeographicLib
{
    ref class Geocentric;
  /**
   * \brief .NET wrapper for GeographicLib::NormalGravity.
   *
   * This class allows .NET applications to access GeographicLib::NormalGravity.
   *
   * "Normal" gravity refers to an idealization of the earth which is modeled
   * as an rotating ellipsoid.  The eccentricity of the ellipsoid, the rotation
   * speed, and the distribution of mass within the ellipsoid are such that the
   * surface of the ellipsoid is a surface of constant potential (gravitational
   * plus centrifugal).  The acceleration due to gravity is therefore
   * perpendicular to the surface of the ellipsoid.
   *
   * There is a closed solution to this problem which is implemented here.
   * Series "approximations" are only used to evaluate certain combinations of
   * elementary functions where use of the closed expression results in a loss
   * of accuracy for small arguments due to cancellation of the two leading
   * terms.  However these series include sufficient terms to give full machine
   * precision.
   *
   * Definitions:
   * - <i>V</i><sub>0</sub>, the gravitational contribution to the normal
   *   potential;
   * - &Phi;, the rotational contribution to the normal potential;
   * - \e U = <i>V</i><sub>0</sub> + &Phi;, the total
   *   potential;
   * - <b>&Gamma;</b> = &nabla;<i>V</i><sub>0</sub>, the acceleration due to
   *   mass of the earth;
   * - <b>f</b> = &nabla;&Phi;, the centrifugal acceleration;
   * - <b>&gamma;</b> = &nabla;\e U = <b>&Gamma;</b> + <b>f</b>, the normal
   *   acceleration;
   * - \e X, \e Y, \e Z, geocentric coordinates;
   * - \e x, \e y, \e z, local cartesian coordinates used to denote the east,
   *   north and up directions.
   *
   * References:
   * - W. A. Heiskanen and H. Moritz, Physical Geodesy (Freeman, San
   *   Francisco, 1967), Secs. 1-19, 2-7, 2-8 (2-9, 2-10), 6-2 (6-3).
   * - H. Moritz, Geodetic Reference System 1980, J. Geodesy 54(3), 395-405
   *   (1980) http://dx.doi.org/10.1007/BF02521480
   *
   * C# Example:
   * \include example-NormalGravity.cs
   * Managed C++ Example:
   * \include example-NormalGravity.cpp
   * Visual Basic Example:
   * \include example-NormalGravity.vb
   *
   * <B>INTERFACE DIFFERENCES:</B><BR>
   * A constructor has been provided for creating standard WGS84 and GRS80
   * gravity models.
   *
   * The following functions are implemented as properties:
   * MajorRadius, MassConstant, AngularVelocity, Flattening,
   * EquatorialGravity, PolarGravity, GravityFlattening, SurfacePotential.
   **********************************************************************/
    public ref class NormalGravity
    {
        private:
        // a pointer to the unmanaged GeographicLib::NormalGravity.
        const GeographicLib::NormalGravity* m_pNormalGravity;

        // the finalizer frees the unmanaged memory when the object is destroyed.
        !NormalGravity(void);
    public:
        /// \cond SKIP
        //! The enumerated standard gravity models.
        enum class StandardModels
        {
            WGS84,  //!< WGS84 gravity model.
            GRS80   //!< GRS80 gravity model.
        };
        /// \endcond

        /** \name Setting up the normal gravity
         **********************************************************************/
        ///@{
        /**
         * Constructor for the normal gravity.
         *
         * @param[in] a equatorial radius (meters).
         * @param[in] GM mass constant of the ellipsoid
         *   (meters<sup>3</sup>/seconds<sup>2</sup>); this is the product of \e G
         *   the gravitational constant and \e M the mass of the earth (usually
         *   including the mass of the earth's atmosphere).
         * @param[in] omega the angular velocity (rad s<sup>&minus;1</sup>).
         * @param[in] f the flattening of the ellipsoid.
         * @param[in] J2 dynamical form factor.
         * @exception if \e a is not positive or the other constants are
         *   inconsistent (see below).
         *
         * Exactly one of \e f and \e J2 should be positive and this will be used
         * to define the ellipsoid.  The shape of the ellipsoid can be given in one
         * of two ways:
         * - geometrically, the ellipsoid is defined by the flattening \e f = (\e a
         *   &minus; \e b) / \e a, where \e a and \e b are the equatorial radius
         *   and the polar semi-axis.
         * - physically, the ellipsoid is defined by the dynamical form factor
         *   <i>J</i><sub>2</sub> = (\e C &minus; \e A) / <i>Ma</i><sup>2</sup>,
         *   where \e A and \e C are the equatorial and polar moments of inertia
         *   and \e M is the mass of the earth.
         **********************************************************************/
        NormalGravity(double a, double GM, double omega, double f, double J2);

        /**
         * A constructor for creating standard gravity models..
         * @param[in] model Specifies the desired model.
         **********************************************************************/
        NormalGravity(StandardModels model);

        /**
         * A constructor that accepts a GeographicLib::NormalGravity.
         * For internal use only.
         * @param g An existing GeographicLib::NormalGravity.
         **********************************************************************/
        NormalGravity( const GeographicLib::NormalGravity& g);
        ///@}

        /**
         * The destructor calls the finalizer.
         **********************************************************************/
        ~NormalGravity()
        { this->!NormalGravity(); }

        /** \name Compute the gravity
         **********************************************************************/
        ///@{
        /**
         * Evaluate the gravity on the surface of the ellipsoid.
         *
         * @param[in] lat the geographic latitude (degrees).
         * @return &gamma; the acceleration due to gravity, positive downwards
         *   (m s<sup>&minus;2</sup>).
         *
         * Due to the axial symmetry of the ellipsoid, the result is independent of
         * the value of the longitude.  This acceleration is perpendicular to the
         * surface of the ellipsoid.  It includes the effects of the earth's
         * rotation.
         **********************************************************************/
        double SurfaceGravity(double lat);

        /**
         * Evaluate the gravity at an arbitrary point above (or below) the
         * ellipsoid.
         *
         * @param[in] lat the geographic latitude (degrees).
         * @param[in] h the height above the ellipsoid (meters).
         * @param[out] gammay the northerly component of the acceleration
         *   (m s<sup>&minus;2</sup>).
         * @param[out] gammaz the upward component of the acceleration
         *   (m s<sup>&minus;2</sup>); this is usually negative.
         * @return \e U the corresponding normal potential.
         *
         * Due to the axial symmetry of the ellipsoid, the result is independent of
         * the value of the longitude and the easterly component of the
         * acceleration vanishes, \e gammax = 0.  The function includes the effects
         * of the earth's rotation.  When \e h = 0, this function gives \e gammay =
         * 0 and the returned value matches that of NormalGravity::SurfaceGravity.
         **********************************************************************/
        double Gravity(double lat, double h,
            [System::Runtime::InteropServices::Out] double% gammay,
            [System::Runtime::InteropServices::Out] double% gammaz);

        /**
         * Evaluate the components of the acceleration due to gravity and the
         * centrifugal acceleration in geocentric coordinates.
         *
         * @param[in] X geocentric coordinate of point (meters).
         * @param[in] Y geocentric coordinate of point (meters).
         * @param[in] Z geocentric coordinate of point (meters).
         * @param[out] gammaX the \e X component of the acceleration
         *   (m s<sup>&minus;2</sup>).
         * @param[out] gammaY the \e Y component of the acceleration
         *   (m s<sup>&minus;2</sup>).
         * @param[out] gammaZ the \e Z component of the acceleration
         *   (m s<sup>&minus;2</sup>).
         * @return \e U = <i>V</i><sub>0</sub> + &Phi; the sum of the
         *   gravitational and centrifugal potentials
         *   (m<sup>2</sup> s<sup>&minus;2</sup>).
         *
         * The acceleration given by <b>&gamma;</b> = &nabla;\e U =
         * &nabla;<i>V</i><sub>0</sub> + &nabla;&Phi; = <b>&Gamma;</b> + <b>f</b>.
         **********************************************************************/
        double U(double X, double Y, double Z,
                     [System::Runtime::InteropServices::Out] double% gammaX,
                     [System::Runtime::InteropServices::Out] double% gammaY,
                     [System::Runtime::InteropServices::Out] double% gammaZ);

        /**
         * Evaluate the components of the acceleration due to gravity alone in
         * geocentric coordinates.
         *
         * @param[in] X geocentric coordinate of point (meters).
         * @param[in] Y geocentric coordinate of point (meters).
         * @param[in] Z geocentric coordinate of point (meters).
         * @param[out] GammaX the \e X component of the acceleration due to gravity
         *   (m s<sup>&minus;2</sup>).
         * @param[out] GammaY the \e Y component of the acceleration due to gravity
         *   (m s<sup>&minus;2</sup>).
         * @param[out] GammaZ the \e Z component of the acceleration due to gravity
         *   (m s<sup>&minus;2</sup>).
         * @return <i>V</i><sub>0</sub> the gravitational potential
         *   (m<sup>2</sup> s<sup>&minus;2</sup>).
         *
         * This function excludes the centrifugal acceleration and is appropriate
         * to use for space applications.  In terrestrial applications, the
         * function NormalGravity::U (which includes this effect) should usually be
         * used.
         **********************************************************************/
        double V0(double X, double Y, double Z,
                      [System::Runtime::InteropServices::Out] double% GammaX,
                      [System::Runtime::InteropServices::Out] double% GammaY,
                      [System::Runtime::InteropServices::Out] double% GammaZ);

        /**
         * Evaluate the centrifugal acceleration in geocentric coordinates.
         *
         * @param[in] X geocentric coordinate of point (meters).
         * @param[in] Y geocentric coordinate of point (meters).
         * @param[out] fX the \e X component of the centrifugal acceleration
         *   (m s<sup>&minus;2</sup>).
         * @param[out] fY the \e Y component of the centrifugal acceleration
         *   (m s<sup>&minus;2</sup>).
         * @return &Phi; the centrifugal potential (m<sup>2</sup>
         *   s<sup>&minus;2</sup>).
         *
         * &Phi; is independent of \e Z, thus \e fZ = 0.  This function
         * NormalGravity::U sums the results of NormalGravity::V0 and
         * NormalGravity::Phi.
         **********************************************************************/
        double Phi(double X, double Y,
            [System::Runtime::InteropServices::Out] double% fX,
            [System::Runtime::InteropServices::Out] double% fY);
        ///@}

        /** \name Inspector functions
         **********************************************************************/
        ///@{
        /**
         * @return \e a the equatorial radius of the ellipsoid (meters).  This is
         *   the value used in the constructor.
         **********************************************************************/
        property double MajorRadius { double get(); }

        /**
         * @return \e GM the mass constant of the ellipsoid
         *   (m<sup>3</sup> s<sup>&minus;2</sup>).  This is the value used in the
         *   constructor.
         **********************************************************************/
        property double MassConstant { double get(); }

        /**
         * @return \e J<sub>n</sub> the dynamical form factors of the ellipsoid.
         *
         * If \e n = 2 (the default), this is the value of <i>J</i><sub>2</sub>
         * used in the constructor.  Otherwise it is the zonal coefficient of the
         * Legendre harmonic sum of the normal gravitational potential.  Note that
         * \e J<sub>n</sub> = 0 if \e n is odd.  In most gravity applications,
         * fully normalized Legendre functions are used and the corresponding
         * coefficient is <i>C</i><sub><i>n</i>0</sub> = &minus;\e J<sub>n</sub> /
         * sqrt(2 \e n + 1).
         **********************************************************************/
        double DynamicalFormFactor(int n);

        /**
         * @return &omega; the angular velocity of the ellipsoid (rad
         *   s<sup>&minus;1</sup>).  This is the value used in the constructor.
         **********************************************************************/
        property double AngularVelocity { double get(); }

        /**
         * @return <i>f</i> the flattening of the ellipsoid (\e a &minus; \e b)/\e
         *   a.
         **********************************************************************/
        property double Flattening { double get(); }

        /**
         * @return &gamma;<sub>e</sub> the normal gravity at equator (m
         *   s<sup>&minus;2</sup>).
         **********************************************************************/
        property double EquatorialGravity { double get(); }

        /**
         * @return &gamma;<sub>p</sub> the normal gravity at poles (m
         *   s<sup>&minus;2</sup>).
         **********************************************************************/
        property double PolarGravity { double get(); }

        /**
         * @return <i>f*</i> the gravity flattening (&gamma;<sub>p</sub> &minus;
         *   &gamma;<sub>e</sub>) / &gamma;<sub>e</sub>.
         **********************************************************************/
        property double GravityFlattening { double get(); }

        /**
         * @return <i>U</i><sub>0</sub> the constant normal potential for the
         *   surface of the ellipsoid (m<sup>2</sup> s<sup>&minus;2</sup>).
         **********************************************************************/
        property double SurfacePotential { double get(); }

        /**
         * @return the Geocentric object used by this instance.
         **********************************************************************/
        Geocentric^ Earth();
        ///@}

        /**
         * A global instantiation of NormalGravity for the WGS84 ellipsoid.
        **********************************************************************/
        static NormalGravity^ WGS84();

        /**
         * A global instantiation of NormalGravity for the GRS80 ellipsoid.
        **********************************************************************/
        static NormalGravity^ GRS80();

        /**
         * Compute the flattening from the dynamical form factor.
         *
         * @param[in] a equatorial radius (meters).
         * @param[in] GM mass constant of the ellipsoid
         *   (meters<sup>3</sup>/seconds<sup>2</sup>); this is the product of \e G
         *   the gravitational constant and \e M the mass of the earth (usually
         *   including the mass of the earth's atmosphere).
         * @param[in] omega the angular velocity (rad s<sup>&minus;1</sup>).
         * @param[in] J2 the dynamical form factor.
         * @return \e f the flattening of the ellipsoid.
         **********************************************************************/
        static double J2ToFlattening(double a, double GM, double omega,
                                     double J2);

        /**
         * Compute the dynamical form factor from the flattening.
         *
         * @param[in] a equatorial radius (meters).
         * @param[in] GM mass constant of the ellipsoid
         *   (meters<sup>3</sup>/seconds<sup>2</sup>); this is the product of \e G
         *   the gravitational constant and \e M the mass of the earth (usually
         *   including the mass of the earth's atmosphere).
         * @param[in] omega the angular velocity (rad s<sup>&minus;1</sup>).
         * @param[in] f the flattening of the ellipsoid.
         * @return \e J2 the dynamical form factor.
         **********************************************************************/
        static double FlatteningToJ2(double a, double GM, double omega,
                                     double f);
    };
} //namespace NETGeographicLib