GeographicLib  1.46
GravityCircle.cpp
Go to the documentation of this file.
1 /**
2  * \file GravityCircle.cpp
3  * \brief Implementation for GeographicLib::GravityCircle class
4  *
7  * http://geographiclib.sourceforge.net/
8  **********************************************************************/
9
11 #include <fstream>
12 #include <sstream>
14
15 namespace GeographicLib {
16
17  using namespace std;
18
19  Math::real GravityCircle::Gravity(real lon, real& gx, real& gy, real& gz)
20  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)
51  const {
52  if ((_caps & SPHERICAL_ANOMALY) != SPHERICAL_ANOMALY) {
53  Dg01 = xi = eta = Math::NaN();
54  return;
55  }
56  real slam, clam;
57  Math::sincosd(lon, slam, clam);
58  real
59  deltax, deltay, deltaz,
60  T = InternalT(slam, clam, deltax, deltay, deltaz, true, false);
61  // Rotate cartesian into spherical coordinates
62  real MC[Geocentric::dim2_];
63  Geocentric::Rotation(_spsi, _cpsi, slam, clam, MC);
64  Geocentric::Unrotate(MC, deltax, deltay, deltaz, deltax, deltay, deltaz);
65  // H+M, Eq 2-151c
66  Dg01 = - deltaz - 2 * T * _invR;
67  xi = -(deltay/_gamma) / Math::degree();
68  eta = -(deltax/_gamma) / Math::degree();
69  }
70
71  Math::real GravityCircle::W(real slam, real clam,
72  real& gX, real& gY, real& gZ) const {
73  real Wres = V(slam, clam, gX, gY, gZ) + _frot * _Px / 2;
74  gX += _frot * clam;
75  gY += _frot * slam;
76  return Wres;
77  }
78
79  Math::real GravityCircle::V(real slam, real clam,
80  real& GX, real& GY, real& GZ)
81  const {
82  if ((_caps & GRAVITY) != GRAVITY) {
83  GX = GY = GZ = Math::NaN();
84  return Math::NaN();
85  }
86  real
87  Vres = _gravitational(slam, clam, GX, GY, GZ),
88  f = _GMmodel / _amodel;
89  Vres *= f;
90  GX *= f;
91  GY *= f;
92  GZ *= f;
93  return Vres;
94  }
95
96  Math::real GravityCircle::InternalT(real slam, real clam,
97  real& deltaX, real& deltaY, real& deltaZ,
98  bool gradp, bool correct) const {
100  if ((_caps & DISTURBANCE) != DISTURBANCE) {
101  deltaX = deltaY = deltaZ = Math::NaN();
102  return Math::NaN();
103  }
104  } else {
105  if ((_caps & DISTURBING_POTENTIAL) != DISTURBING_POTENTIAL)
106  return Math::NaN();
107  }
108  if (_dzonal0 == 0)
109  correct = false;
111  ? _disturbing(slam, clam, deltaX, deltaY, deltaZ)
112  : _disturbing(slam, clam));
113  T = (T / _amodel - (correct ? _dzonal0 : 0) * _invR) * _GMmodel;
115  real f = _GMmodel / _amodel;
116  deltaX *= f;
117  deltaY *= f;
118  deltaZ *= f;
119  if (correct) {
120  real r3 = _GMmodel * _dzonal0 * _invR * _invR * _invR;
121  deltaX += _Px * clam * r3;
122  deltaY += _Px * slam * r3;
123  deltaZ += _Z * r3;
124  }
125  }
126  return T;
127  }
128
129 } // namespace GeographicLib
static T NaN()
Definition: Math.hpp:805
GeographicLib::Math::real real
Definition: GeodSolve.cpp:31
static void sincosd(T x, T &sinx, T &cosx)
Definition: Math.hpp:545
void SphericalAnomaly(real lon, real &Dg01, real &xi, real &eta) const
Math::real Disturbance(real lon, real &deltax, real &deltay, real &deltaz) const
Math::real Gravity(real lon, real &gx, real &gy, real &gz) const
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
static T degree()
Definition: Math.hpp:216