GeographicLib: GravityCircle.hpp Source File

GeographicLib 2.7

Loading...
Searching...
No Matches
GravityCircle.hpp
Go to the documentation of this file.
1/**
2 * \file GravityCircle.hpp
3 * \brief Header for GeographicLib::GravityCircle class
4 *
5 * Copyright (c) Charles Karney (2011-2022) <karney@alum.mit.edu> and licensed
6 * under the MIT/X11 License. For more information, see
7 * https://geographiclib.sourceforge.io/
8 **********************************************************************/
9
10#if !defined(GEOGRAPHICLIB_GRAVITYCIRCLE_HPP)
11#define GEOGRAPHICLIB_GRAVITYCIRCLE_HPP 1
12
13#include <vector>
14#include <GeographicLib/Constants.hpp>
15#include <GeographicLib/CircularEngine.hpp>
16#include <GeographicLib/GravityModel.hpp>
17
18namespace GeographicLib {
19
20 /**
21 * \brief Gravity on a circle of latitude
22 *
23 * Evaluate the earth's gravity field on a circle of constant height and
24 * latitude. This uses a CircularEngine to pre-evaluate the inner sum of the
25 * spherical harmonic sum, allowing the values of the field at several
26 * different longitudes to be evaluated rapidly.
27 *
28 * Use GravityModel::Circle to create a GravityCircle object. (The
29 * constructor for this class is private.)
30 *
31 * See \ref gravityparallel for an example of using GravityCircle (together
32 * with OpenMP) to speed up the computation of geoid heights.
33 *
34 * Example of use:
35 * \include example-GravityCircle.cpp
36 *
37 * <a href="Gravity.1.html">Gravity</a> is a command-line utility providing
38 * access to the functionality of GravityModel and GravityCircle.
39 **********************************************************************/
40
41 class GEOGRAPHICLIB_EXPORT GravityCircle {
42 private:
43 typedef Math::real real;
44 enum mask {
45 NONE = GravityModel::NONE,
46 GRAVITY = GravityModel::GRAVITY,
47 DISTURBANCE = GravityModel::DISTURBANCE,
48 DISTURBING_POTENTIAL = GravityModel::DISTURBING_POTENTIAL,
49 GEOID_HEIGHT = GravityModel::GEOID_HEIGHT,
50 SPHERICAL_ANOMALY = GravityModel::SPHERICAL_ANOMALY,
51 ALL = GravityModel::ALL,
52 };
53
54 unsigned _caps;
55 real _a, _f, _lat, _h, _zZ, _pPx, _invR, _cpsi, _spsi,
56 _cphi, _sphi, _amodel, _gGMmodel, _dzonal0,
57 _corrmult, _gamma0, _gamma, _frot;
58 CircularEngine _gravitational, _disturbing, _correction;
59
60 GravityCircle(mask caps, real a, real f, real lat, real h,
61 real Z, real P, real cphi, real sphi,
62 real amodel, real GMmodel,
63 real dzonal0, real corrmult,
64 real gamma0, real gamma, real frot,
65 const CircularEngine& gravitational,
66 const CircularEngine& disturbing,
67 const CircularEngine& correction);
68
69 friend class GravityModel; // GravityModel calls the private constructor
70 Math::real W(real slam, real clam,
71 real& gX, real& gY, real& gZ) const;
72 Math::real V(real slam, real clam,
73 real& gX, real& gY, real& gZ) const;
74 Math::real InternalT(real slam, real clam,
75 real& deltaX, real& deltaY, real& deltaZ,
76 bool gradp, bool correct) const;
77 public:
78 /**
79 * A default constructor for the normal gravity. This sets up an
80 * uninitialized object which can be later replaced by the
81 * GravityModel::Circle.
82 **********************************************************************/
83 GravityCircle() : _a(-1) {}
84
85 /** \name Compute the gravitational field
86 **********************************************************************/
87 ///@{
88 /**
89 * Evaluate the gravity.
90 *
91 * @param[in] lon the geographic longitude (degrees).
92 * @param[out] gx the easterly component of the acceleration
93 * (m s<sup>&minus;2</sup>).
94 * @param[out] gy the northerly component of the acceleration
95 * (m s<sup>&minus;2</sup>).
96 * @param[out] gz the upward component of the acceleration
97 * (m s<sup>&minus;2</sup>); this is usually negative.
98 * @return \e W the sum of the gravitational and centrifugal potentials
99 * (m<sup>2</sup> s<sup>&minus;2</sup>).
100 *
101 * The function includes the effects of the earth's rotation.
102 **********************************************************************/
103 Math::real Gravity(real lon, real& gx, real& gy, real& gz) const;
104
105 /**
106 * Evaluate the gravity disturbance vector.
107 *
108 * @param[in] lon the geographic longitude (degrees).
109 * @param[out] deltax the easterly component of the disturbance vector
110 * (m s<sup>&minus;2</sup>).
111 * @param[out] deltay the northerly component of the disturbance vector
112 * (m s<sup>&minus;2</sup>).
113 * @param[out] deltaz the upward component of the disturbance vector
114 * (m s<sup>&minus;2</sup>).
115 * @return \e T the corresponding disturbing potential
116 * (m<sup>2</sup> s<sup>&minus;2</sup>).
117 **********************************************************************/
118 Math::real Disturbance(real lon, real& deltax, real& deltay, real& deltaz)
119 const;
120
121 /**
122 * Evaluate the geoid height.
123 *
124 * @param[in] lon the geographic longitude (degrees).
125 * @return \e N the height of the geoid above the reference ellipsoid
126 * (meters).
127 *
128 * Some approximations are made in computing the geoid height so that the
129 * results of the NGA codes are reproduced accurately. Details are given
130 * in \ref gravitygeoid.
131 **********************************************************************/
132 Math::real GeoidHeight(real lon) const;
133
134 /**
135 * Evaluate the components of the gravity anomaly vector using the
136 * spherical approximation.
137 *
138 * @param[in] lon the geographic longitude (degrees).
139 * @param[out] Dg01 the gravity anomaly (m s<sup>&minus;2</sup>).
140 * @param[out] xi the northerly component of the deflection of the vertical
141 * (degrees).
142 * @param[out] eta the easterly component of the deflection of the vertical
143 * (degrees).
144 *
145 * The spherical approximation (see Heiskanen and Moritz, Sec 2-14) is used
146 * so that the results of the NGA codes are reproduced accurately.
147 * approximations used here. Details are given in \ref gravitygeoid.
148 **********************************************************************/
149 void SphericalAnomaly(real lon, real& Dg01, real& xi, real& eta)
150 const;
151
152 /**
153 * Evaluate the components of the acceleration due to gravity and the
154 * centrifugal acceleration in geocentric coordinates.
155 *
156 * @param[in] lon the geographic longitude (degrees).
157 * @param[out] gX the \e X component of the acceleration
158 * (m s<sup>&minus;2</sup>).
159 * @param[out] gY the \e Y component of the acceleration
160 * (m s<sup>&minus;2</sup>).
161 * @param[out] gZ the \e Z component of the acceleration
162 * (m s<sup>&minus;2</sup>).
163 * @return \e W = \e V + &Phi; the sum of the gravitational and
164 * centrifugal potentials (m<sup>2</sup> s<sup>&minus;2</sup>).
165 **********************************************************************/
166 Math::real W(real lon, real& gX, real& gY, real& gZ) const {
167 real slam, clam;
168 Math::sincosd(lon, slam, clam);
169 return W(slam, clam, gX, gY, gZ);
170 }
171
172 /**
173 * Evaluate the components of the acceleration due to gravity in geocentric
174 * coordinates.
175 *
176 * @param[in] lon the geographic longitude (degrees).
177 * @param[out] GX the \e X component of the acceleration
178 * (m s<sup>&minus;2</sup>).
179 * @param[out] GY the \e Y component of the acceleration
180 * (m s<sup>&minus;2</sup>).
181 * @param[out] GZ the \e Z component of the acceleration
182 * (m s<sup>&minus;2</sup>).
183 * @return \e V = \e W - &Phi; the gravitational potential
184 * (m<sup>2</sup> s<sup>&minus;2</sup>).
185 **********************************************************************/
186 Math::real V(real lon, real& GX, real& GY, real& GZ) const {
187 real slam, clam;
188 Math::sincosd(lon, slam, clam);
189 return V(slam, clam, GX, GY, GZ);
190 }
191
192 /**
193 * Evaluate the components of the gravity disturbance in geocentric
194 * coordinates.
195 *
196 * @param[in] lon the geographic longitude (degrees).
197 * @param[out] deltaX the \e X component of the gravity disturbance
198 * (m s<sup>&minus;2</sup>).
199 * @param[out] deltaY the \e Y component of the gravity disturbance
200 * (m s<sup>&minus;2</sup>).
201 * @param[out] deltaZ the \e Z component of the gravity disturbance
202 * (m s<sup>&minus;2</sup>).
203 * @return \e T = \e W - \e U the disturbing potential (also called the
204 * anomalous potential) (m<sup>2</sup> s<sup>&minus;2</sup>).
205 **********************************************************************/
206 Math::real T(real lon, real& deltaX, real& deltaY, real& deltaZ)
207 const {
208 real slam, clam;
209 Math::sincosd(lon, slam, clam);
210 return InternalT(slam, clam, deltaX, deltaY, deltaZ, true, true);
211 }
212
213 /**
214 * Evaluate disturbing potential in geocentric coordinates.
215 *
216 * @param[in] lon the geographic longitude (degrees).
217 * @return \e T = \e W - \e U the disturbing potential (also called the
218 * anomalous potential) (m<sup>2</sup> s<sup>&minus;2</sup>).
219 **********************************************************************/
220 Math::real T(real lon) const {
221 real slam, clam, dummy;
222 Math::sincosd(lon, slam, clam);
223 return InternalT(slam, clam, dummy, dummy, dummy, false, true);
224 }
225
226 ///@}
227
228 /** \name Inspector functions
229 **********************************************************************/
230 ///@{
231 /**
232 * @return true if the object has been initialized.
233 **********************************************************************/
234 bool Init() const { return _a > 0; }
235
236 /**
237 * @return \e a the equatorial radius of the ellipsoid (meters). This is
238 * the value inherited from the GravityModel object used in the
239 * constructor.
240 **********************************************************************/
241 Math::real EquatorialRadius() const
242 { return Init() ? _a : Math::NaN(); }
243
244 /**
245 * @return \e f the flattening of the ellipsoid. This is the value
246 * inherited from the GravityModel object used in the constructor.
247 **********************************************************************/
248 Math::real Flattening() const
249 { return Init() ? _f : Math::NaN(); }
250
251 /**
252 * @return the latitude of the circle (degrees).
253 **********************************************************************/
254 Math::real Latitude() const
255 { return Init() ? _lat : Math::NaN(); }
256
257 /**
258 * @return the height of the circle (meters).
259 **********************************************************************/
260 Math::real Height() const
261 { return Init() ? _h : Math::NaN(); }
262
263 /**
264 * @return \e caps the computational capabilities that this object was
265 * constructed with.
266 **********************************************************************/
267 unsigned Capabilities() const { return _caps; }
268
269 /**
270 * @param[in] testcaps a set of bitor'ed GravityModel::mask values.
271 * @return true if the GravityCircle object has all these capabilities.
272 **********************************************************************/
273 bool Capabilities(unsigned testcaps) const {
274 return (_caps & testcaps) == testcaps;
275 }
276 ///@}
277 };
278
279} // namespace GeographicLib
280
281#endif // GEOGRAPHICLIB_GRAVITYCIRCLE_HPP
CircularEngine.hpp
Header for GeographicLib::CircularEngine class.
Constants.hpp
Header for GeographicLib::Constants class.
GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_EXPORT
Definition Constants.hpp:59
real
GeographicLib::Math::real real
Definition Geod3Solve.cpp:25
GravityModel.hpp
Header for GeographicLib::GravityModel class.
GeographicLib::CircularEngine
Spherical harmonic sums for a circle.
Definition CircularEngine.hpp:52
GeographicLib::GravityCircle::Capabilities
unsigned Capabilities() const
Definition GravityCircle.hpp:267
GeographicLib::GravityCircle::EquatorialRadius
Math::real EquatorialRadius() const
Definition GravityCircle.hpp:241
GeographicLib::GravityCircle::Init
bool Init() const
Definition GravityCircle.hpp:234
GeographicLib::GravityCircle::V
Math::real V(real lon, real &GX, real &GY, real &GZ) const
Definition GravityCircle.hpp:186
GeographicLib::GravityCircle::GravityCircle
GravityCircle()
Definition GravityCircle.hpp:83
GeographicLib::GravityCircle::Height
Math::real Height() const
Definition GravityCircle.hpp:260
GeographicLib::GravityCircle::W
Math::real W(real lon, real &gX, real &gY, real &gZ) const
Definition GravityCircle.hpp:166
GeographicLib::GravityCircle::Latitude
Math::real Latitude() const
Definition GravityCircle.hpp:254
GeographicLib::GravityCircle::Flattening
Math::real Flattening() const
Definition GravityCircle.hpp:248
GeographicLib::GravityCircle::T
Math::real T(real lon, real &deltaX, real &deltaY, real &deltaZ) const
Definition GravityCircle.hpp:206
GeographicLib::GravityCircle::Capabilities
bool Capabilities(unsigned testcaps) const
Definition GravityCircle.hpp:273
GeographicLib::GravityCircle::GravityModel
friend class GravityModel
Definition GravityCircle.hpp:69
GeographicLib::GravityCircle::T
Math::real T(real lon) const
Definition GravityCircle.hpp:220
GeographicLib::GravityModel::GEOID_HEIGHT
@ GEOID_HEIGHT
Definition GravityModel.hpp:155
GeographicLib::GravityModel::DISTURBANCE
@ DISTURBANCE
Definition GravityModel.hpp:139
GeographicLib::GravityModel::ALL
@ ALL
Definition GravityModel.hpp:160
GeographicLib::GravityModel::DISTURBING_POTENTIAL
@ DISTURBING_POTENTIAL
Definition GravityModel.hpp:145
GeographicLib::GravityModel::SPHERICAL_ANOMALY
@ SPHERICAL_ANOMALY
Definition GravityModel.hpp:150
GeographicLib::GravityModel::NONE
@ NONE
Definition GravityModel.hpp:128
GeographicLib::GravityModel::GRAVITY
@ GRAVITY
Definition GravityModel.hpp:134
GeographicLib::Math::sincosd
static void sincosd(T x, T &sinx, T &cosx)
Definition Math.cpp:104
GeographicLib::Math::NaN
static T NaN()
Definition Math.cpp:301
GeographicLib::Math::real
double real
Definition Math.hpp:115
GeographicLib
Namespace for GeographicLib.
Definition Accumulator.cpp:12