GeographicLib  1.44
Ellipsoid.cpp
Go to the documentation of this file.
1 /**
2  * \file Ellipsoid.cpp
3  * \brief Implementation for GeographicLib::Ellipsoid class
4  *
5  * Copyright (c) Charles Karney (2012-2015) <charles@karney.com> and licensed
6  * under the MIT/X11 License. For more information, see
7  * http://geographiclib.sourceforge.net/
8  **********************************************************************/
9 
11 
12 namespace GeographicLib {
13 
14  using namespace std;
15 
16  Ellipsoid::Ellipsoid(real a, real f)
17  : stol_(real(0.01) * sqrt(numeric_limits<real>::epsilon()))
18  , _a(a)
19  , _f(f <= 1 ? f : 1/f)
20  , _f1(1 - _f)
21  , _f12(Math::sq(_f1))
22  , _e2(_f * (2 - _f))
23  , _es((_f < 0 ? -1 : 1) * sqrt(abs(_e2)))
24  , _e12(_e2 / (1 - _e2))
25  , _n(_f / (2 - _f))
26  , _b(_a * _f1)
27  , _tm(_a, _f, real(1))
28  , _ell(-_e12)
29  , _au(_a, _f, real(0), real(1), real(0), real(1), real(1))
30  {}
31 
33  static const Ellipsoid wgs84(Constants::WGS84_a(), Constants::WGS84_f());
34  return wgs84;
35  }
36 
38  { return _b * _ell.E(); }
39 
41  return 4 * Math::pi() *
42  ((Math::sq(_a) + Math::sq(_b) *
43  (_e2 == 0 ? 1 :
44  (_e2 > 0 ? Math::atanh(sqrt(_e2)) : atan(sqrt(-_e2))) /
45  sqrt(abs(_e2))))/2);
46  }
47 
49  { return Math::atand(_f1 * Math::tand(Math::LatFix(phi))); }
50 
52  { return Math::atand(Math::tand(Math::LatFix(beta)) / _f1); }
53 
55  { return Math::atand(_f12 * Math::tand(Math::LatFix(phi))); }
56 
58  { return Math::atand(Math::tand(Math::LatFix(theta)) / _f12); }
59 
61  return abs(phi) == 90 ? phi:
62  90 * MeridianDistance(phi) / QuarterMeridian();
63  }
64 
66  if (abs(mu) == 90)
67  return mu;
68  return InverseParametricLatitude(_ell.Einv(mu * _ell.E() / 90) /
69  Math::degree());
70  }
71 
73  { return Math::atand(_au.txif(Math::tand(Math::LatFix(phi)))); }
74 
76  { return Math::atand(_au.tphif(Math::tand(Math::LatFix(xi)))); }
77 
79  { return Math::atand(Math::taupf(Math::tand(Math::LatFix(phi)), _es)); }
80 
82  { return Math::atand(Math::tauf(Math::tand(Math::LatFix(chi)), _es)); }
83 
85  { return Math::asinh(Math::taupf(Math::tand(Math::LatFix(phi)), _es)) /
86  Math::degree(); }
87 
89  { return Math::atand(Math::tauf(sinh(psi * Math::degree()), _es)); }
90 
92  return abs(phi) == 90 ? 0 :
93  // a * cos(beta)
94  _a / Math::hypot(real(1), _f1 * Math::tand(Math::LatFix(phi)));
95  }
96 
98  real tbeta = _f1 * Math::tand(phi);
99  // b * sin(beta)
100  return _b * tbeta / Math::hypot(real(1),
101  _f1 * Math::tand(Math::LatFix(phi)));
102  }
103 
105  { return _b * _ell.Ed( ParametricLatitude(phi) ); }
106 
108  real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
109  return _a * (1 - _e2) / (v * sqrt(v));
110  }
111 
113  real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
114  return _a / sqrt(v);
115  }
116 
118  const {
119  real calp, salp,
120  v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
121  Math::sincosd(azi, salp, calp);
122  return _a / (sqrt(v) * (Math::sq(calp) * v / (1 - _e2) + Math::sq(salp)));
123  }
124 
125 } // namespace GeographicLib
Ellipsoid(real a, real f)
Definition: Ellipsoid.cpp:16
Math::real CircleHeight(real phi) const
Definition: Ellipsoid.cpp:97
Math::real InverseRectifyingLatitude(real mu) const
Definition: Ellipsoid.cpp:65
Math::real IsometricLatitude(real phi) const
Definition: Ellipsoid.cpp:84
Math::real InverseParametricLatitude(real beta) const
Definition: Ellipsoid.cpp:51
static T pi()
Definition: Math.hpp:216
static T atand(T x)
Definition: Math.hpp:708
Math::real TransverseCurvatureRadius(real phi) const
Definition: Ellipsoid.cpp:112
Math::real InverseAuthalicLatitude(real xi) const
Definition: Ellipsoid.cpp:75
static T LatFix(T x)
Definition: Math.hpp:482
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:102
static T sind(T x)
Definition: Math.hpp:597
static void sincosd(T x, T &sinx, T &cosx)
Definition: Math.hpp:559
static T atanh(T x)
Definition: Math.hpp:342
Math::real AuthalicLatitude(real phi) const
Definition: Ellipsoid.cpp:72
static T asinh(T x)
Definition: Math.hpp:325
Math::real ParametricLatitude(real phi) const
Definition: Ellipsoid.cpp:48
Math::real RectifyingLatitude(real phi) const
Definition: Ellipsoid.cpp:60
Math::real Ed(real ang) const
static T hypot(T x, T y)
Definition: Math.hpp:257
Math::real GeocentricLatitude(real phi) const
Definition: Ellipsoid.cpp:54
Math::real Einv(real x) const
static T sq(T x)
Definition: Math.hpp:246
Math::real InverseConformalLatitude(real chi) const
Definition: Ellipsoid.cpp:81
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
Math::real QuarterMeridian() const
Definition: Ellipsoid.cpp:37
Math::real MeridianDistance(real phi) const
Definition: Ellipsoid.cpp:104
static T degree()
Definition: Math.hpp:230
Header for GeographicLib::Ellipsoid class.
Math::real InverseIsometricLatitude(real psi) const
Definition: Ellipsoid.cpp:88
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
static T tand(T x)
Definition: Math.hpp:656
static T tauf(T taup, T es)
Math::real ConformalLatitude(real phi) const
Definition: Ellipsoid.cpp:78
Math::real Area() const
Definition: Ellipsoid.cpp:40
Math::real NormalCurvatureRadius(real phi, real azi) const
Definition: Ellipsoid.cpp:117
Math::real InverseGeocentricLatitude(real theta) const
Definition: Ellipsoid.cpp:57
Math::real CircleRadius(real phi) const
Definition: Ellipsoid.cpp:91
static const Ellipsoid & WGS84()
Definition: Ellipsoid.cpp:32
Math::real MeridionalCurvatureRadius(real phi) const
Definition: Ellipsoid.cpp:107
static T taupf(T tau, T es)