GeographicLib  1.35
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) <charles@karney.com> and licensed under
6  * 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  const Math::real Ellipsoid::stol_ =
17  0.01 * sqrt(numeric_limits<real>::epsilon());
18 
19  Ellipsoid::Ellipsoid(real a, real f)
20  : _a(a)
21  , _f(f <= 1 ? f : 1/f)
22  , _f1(1 - _f)
23  , _f12(Math::sq(_f1))
24  , _e2(_f * (2 - _f))
25  , _e12(_e2 / (1 - _e2))
26  , _n(_f / (2 - _f))
27  , _b(_a * _f1)
28  , _tm(_a, _f, real(1))
29  , _ell(-_e12)
30  , _au(_a, _f, real(0), real(1), real(0), real(1), real(1))
31  {}
32 
33  const Ellipsoid Ellipsoid::WGS84(Constants::WGS84_a<real>(),
34  Constants::WGS84_f<real>());
35 
37  { return _b * _ell.E(); }
38 
39  Math::real Ellipsoid::Area() const throw() {
40  return 4 * Math::pi<real>() *
41  ((Math::sq(_a) + Math::sq(_b) *
42  (_e2 == 0 ? 1 :
43  (_e2 > 0 ? Math::atanh(sqrt(_e2)) : atan(sqrt(-_e2))) /
44  sqrt(abs(_e2))))/2);
45  }
46 
47  Math::real Ellipsoid::ParametricLatitude(real phi) const throw()
48  { return atand(_f1 * tand(phi)); }
49 
51  { return atand(tand(beta) / _f1); }
52 
53  Math::real Ellipsoid::GeocentricLatitude(real phi) const throw()
54  { return atand(_f12 * tand(phi)); }
55 
57  { return atand(tand(theta) / _f12); }
58 
59  Math::real Ellipsoid::RectifyingLatitude(real phi) const throw() {
60  return abs(phi) == 90 ? phi:
61  90 * MeridianDistance(phi) / QuarterMeridian();
62  }
63 
65  if (abs(mu) == 90)
66  return mu;
67  return InverseParametricLatitude(_ell.Einv(mu * _ell.E() / 90) /
68  Math::degree<real>());
69  }
70 
71  Math::real Ellipsoid::AuthalicLatitude(real phi) const throw()
72  { return atand(_au.txif(tand(phi))); }
73 
75  { return atand(_au.tphif(tand(xi))); }
76 
77  Math::real Ellipsoid::ConformalLatitude(real phi) const throw()
78  { return atand(_tm.taupf(tand(phi))); }
79 
81  { return atand(_tm.tauf(tand(chi))); }
82 
83  Math::real Ellipsoid::IsometricLatitude(real phi) const throw()
84  { return Math::asinh(_tm.taupf(tand(phi))) / Math::degree<real>(); }
85 
87  { return atand(_tm.tauf(sinh(psi * Math::degree<real>()))); }
88 
89  Math::real Ellipsoid::CircleRadius(real phi) const throw() {
90  return abs(phi) == 90 ? 0 :
91  // a * cos(beta)
92  _a / Math::hypot(real(1), _f1 * tand(phi));
93  }
94 
95  Math::real Ellipsoid::CircleHeight(real phi) const throw() {
96  real tbeta = _f1 * tand(phi);
97  // b * sin(beta)
98  return _b * tbeta / Math::hypot(real(1), _f1 * tand(phi));
99  }
100 
101  Math::real Ellipsoid::MeridianDistance(real phi) const throw()
102  { return _b * _ell.Ed( ParametricLatitude(phi) ); }
103 
105  real v = 1 - _e2 * Math::sq(sin(phi * Math::degree<real>()));
106  return _a * (1 - _e2) / (v * sqrt(v));
107  }
108 
110  real v = 1 - _e2 * Math::sq(sin(phi * Math::degree<real>()));
111  return _a / sqrt(v);
112  }
113 
115  const throw() {
116  real
117  alpha = azi * Math::degree<real>(),
118  v = 1 - _e2 * Math::sq(sin(phi * Math::degree<real>()));
119  return _a / (sqrt(v) *
120  (Math::sq(cos(alpha)) * v / (1 - _e2) + Math::sq(sin(alpha))));
121  }
122 
123 } // namespace GeographicLib
Ellipsoid(real a, real f)
Definition: Ellipsoid.cpp:19
Math::real CircleHeight(real phi) const
Definition: Ellipsoid.cpp:95
Math::real InverseRectifyingLatitude(real mu) const
Definition: Ellipsoid.cpp:64
Math::real IsometricLatitude(real phi) const
Definition: Ellipsoid.cpp:83
Math::real InverseParametricLatitude(real beta) const
Definition: Ellipsoid.cpp:50
GeographicLib::Math::real real
Definition: GeodSolve.cpp:40
Math::real TransverseCurvatureRadius(real phi) const
Definition: Ellipsoid.cpp:109
Math::real InverseAuthalicLatitude(real xi) const
Definition: Ellipsoid.cpp:74
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:73
static T atanh(T x)
Definition: Math.hpp:315
Math::real AuthalicLatitude(real phi) const
Definition: Ellipsoid.cpp:71
static T asinh(T x)
Definition: Math.hpp:288
Math::real ParametricLatitude(real phi) const
Definition: Ellipsoid.cpp:47
Math::real RectifyingLatitude(real phi) const
Definition: Ellipsoid.cpp:59
static T hypot(T x, T y)
Definition: Math.hpp:165
Math::real GeocentricLatitude(real phi) const
Definition: Ellipsoid.cpp:53
static const Ellipsoid WGS84
Definition: Ellipsoid.hpp:531
static T sq(T x)
Definition: Math.hpp:153
Math::real InverseConformalLatitude(real chi) const
Definition: Ellipsoid.cpp:80
Math::real QuarterMeridian() const
Definition: Ellipsoid.cpp:36
Math::real MeridianDistance(real phi) const
Definition: Ellipsoid.cpp:101
Header for GeographicLib::Ellipsoid class.
Math::real InverseIsometricLatitude(real psi) const
Definition: Ellipsoid.cpp:86
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
Math::real ConformalLatitude(real phi) const
Definition: Ellipsoid.cpp:77
Math::real Area() const
Definition: Ellipsoid.cpp:39
Math::real NormalCurvatureRadius(real phi, real azi) const
Definition: Ellipsoid.cpp:114
Math::real InverseGeocentricLatitude(real theta) const
Definition: Ellipsoid.cpp:56
Math::real CircleRadius(real phi) const
Definition: Ellipsoid.cpp:89
Math::real MeridionalCurvatureRadius(real phi) const
Definition: Ellipsoid.cpp:104