GeographicLib  1.37
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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) <charles@karney.com> and licensed under
6  * the MIT/X11 License. For more information, see
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 clam, slam, M[Geocentric::dim2_];
22  CircularEngine::cossin(lon, clam, slam);
23  real Wres = W(clam, slam, 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 clam, slam, M[Geocentric::dim2_];
32  CircularEngine::cossin(lon, clam, slam);
33  real Tres = InternalT(clam, slam, 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 clam, slam, dummy;
43  CircularEngine::cossin(lon, clam, slam);
44  real T = InternalT(clam, slam, dummy, dummy, dummy, false, false);
45  real correction = _corrmult * _correction(clam, slam);
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 clam, slam;
57  CircularEngine::cossin(lon, clam, slam);
58  real
59  deltax, deltay, deltaz,
60  T = InternalT(clam, slam, 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 clam, real slam,
72  real& gX, real& gY, real& gZ) const {
73  real Wres = V(clam, slam, 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 clam, real slam,
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(clam, slam, 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 clam, real slam,
97  real& deltaX, real& deltaY, real& deltaZ,
98  bool gradp, bool correct) const {
99  if (gradp) {
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;
110  real T = (gradp
111  ? _disturbing(clam, slam, deltaX, deltaY, deltaZ)
112  : _disturbing(clam, slam));
113  T = (T / _amodel - (correct ? _dzonal0 : 0) * _invR) * _GMmodel;
114  if (gradp) {
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:460
GeographicLib::Math::real real
Definition: GeodSolve.cpp:40
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
static T degree()
Definition: Math.hpp:227
Header for GeographicLib::Geocentric class.
Math::real GeoidHeight(real lon) const
Header for GeographicLib::GravityCircle class.