GeographicLib  1.49
GravityCircle.cpp
Go to the documentation of this file.
1 /**
2  * \file GravityCircle.cpp
3  * \brief Implementation for GeographicLib::GravityCircle class
4  *
5  * Copyright (c) Charles Karney (2011-2015) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * https://geographiclib.sourceforge.io/
8  **********************************************************************/
9 
11 #include <fstream>
12 #include <sstream>
14 
15 namespace GeographicLib {
16 
17  using namespace std;
18 
20  real& gx, real& gy, real& gz) const {
21  real slam, clam, M[Geocentric::dim2_];
22  Math::sincosd(lon, slam, clam);
23  real Wres = W(slam, clam, gx, gy, gz);
24  Geocentric::Rotation(_sphi, _cphi, slam, clam, M);
25  Geocentric::Unrotate(M, gx, gy, gz, gx, gy, gz);
26  return Wres;
27  }
28 
29  Math::real GravityCircle::Disturbance(real lon, real& deltax, real& deltay,
30  real& deltaz) const {
31  real slam, clam, M[Geocentric::dim2_];
32  Math::sincosd(lon, slam, clam);
33  real Tres = InternalT(slam, clam, deltax, deltay, deltaz, true, true);
34  Geocentric::Rotation(_sphi, _cphi, slam, clam, M);
35  Geocentric::Unrotate(M, deltax, deltay, deltaz, deltax, deltay, deltaz);
36  return Tres;
37  }
38 
40  if ((_caps & GEOID_HEIGHT) != GEOID_HEIGHT)
41  return Math::NaN();
42  real slam, clam, dummy;
43  Math::sincosd(lon, slam, clam);
44  real T = InternalT(slam, clam, dummy, dummy, dummy, false, false);
45  real correction = _corrmult * _correction(slam, clam);
46  return T/_gamma0 + correction;
47  }
48 
50  real& Dg01, real& xi, real& eta) const {
51  if ((_caps & SPHERICAL_ANOMALY) != SPHERICAL_ANOMALY) {
52  Dg01 = xi = eta = Math::NaN();
53  return;
54  }
55  real slam, clam;
56  Math::sincosd(lon, slam, clam);
57  real
58  deltax, deltay, deltaz,
59  T = InternalT(slam, clam, deltax, deltay, deltaz, true, false);
60  // Rotate cartesian into spherical coordinates
61  real MC[Geocentric::dim2_];
62  Geocentric::Rotation(_spsi, _cpsi, slam, clam, MC);
63  Geocentric::Unrotate(MC, deltax, deltay, deltaz, deltax, deltay, deltaz);
64  // H+M, Eq 2-151c
65  Dg01 = - deltaz - 2 * T * _invR;
66  xi = -(deltay/_gamma) / Math::degree();
67  eta = -(deltax/_gamma) / Math::degree();
68  }
69 
70  Math::real GravityCircle::W(real slam, real clam,
71  real& gX, real& gY, real& gZ) const {
72  real Wres = V(slam, clam, gX, gY, gZ) + _frot * _Px / 2;
73  gX += _frot * clam;
74  gY += _frot * slam;
75  return Wres;
76  }
77 
78  Math::real GravityCircle::V(real slam, real clam,
79  real& GX, real& GY, real& GZ) const {
80  if ((_caps & GRAVITY) != GRAVITY) {
81  GX = GY = GZ = Math::NaN();
82  return Math::NaN();
83  }
84  real
85  Vres = _gravitational(slam, clam, GX, GY, GZ),
86  f = _GMmodel / _amodel;
87  Vres *= f;
88  GX *= f;
89  GY *= f;
90  GZ *= f;
91  return Vres;
92  }
93 
94  Math::real GravityCircle::InternalT(real slam, real clam,
95  real& deltaX, real& deltaY, real& deltaZ,
96  bool gradp, bool correct) const {
97  if (gradp) {
98  if ((_caps & DISTURBANCE) != DISTURBANCE) {
99  deltaX = deltaY = deltaZ = Math::NaN();
100  return Math::NaN();
101  }
102  } else {
103  if ((_caps & DISTURBING_POTENTIAL) != DISTURBING_POTENTIAL)
104  return Math::NaN();
105  }
106  if (_dzonal0 == 0)
107  correct = false;
108  real T = (gradp
109  ? _disturbing(slam, clam, deltaX, deltaY, deltaZ)
110  : _disturbing(slam, clam));
111  T = (T / _amodel - (correct ? _dzonal0 : 0) * _invR) * _GMmodel;
112  if (gradp) {
113  real f = _GMmodel / _amodel;
114  deltaX *= f;
115  deltaY *= f;
116  deltaZ *= f;
117  if (correct) {
118  real r3 = _GMmodel * _dzonal0 * _invR * _invR * _invR;
119  deltaX += _Px * clam * r3;
120  deltaY += _Px * slam * r3;
121  deltaZ += _Z * r3;
122  }
123  }
124  return T;
125  }
126 
127 } // namespace GeographicLib
static T NaN()
Definition: Math.hpp:830
static void sincosd(T x, T &sinx, T &cosx)
Definition: Math.hpp:558
Math::real Gravity(real lon, real &gx, real &gy, real &gz) const
Math::real Disturbance(real lon, real &deltax, real &deltay, real &deltaz) const
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
static T degree()
Definition: Math.hpp:216
void SphericalAnomaly(real lon, real &Dg01, real &xi, real &eta) const
Header for GeographicLib::Geocentric class.
Header for GeographicLib::GravityCircle class.
Math::real GeoidHeight(real lon) const