GeographicLib  1.38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-2014) <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  , _e(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 atand(_f1 * tand(phi)); }
50 
52  { return atand(tand(beta) / _f1); }
53 
55  { return atand(_f12 * tand(phi)); }
56 
58  { return atand(tand(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 atand(_au.txif(tand(phi))); }
74 
76  { return atand(_au.tphif(tand(xi))); }
77 
79  { return atand(_tm.taupf(tand(phi))); }
80 
82  { return atand(_tm.tauf(tand(chi))); }
83 
85  { return Math::asinh(_tm.taupf(tand(phi))) / Math::degree(); }
86 
88  { return atand(_tm.tauf(sinh(psi * Math::degree()))); }
89 
91  return abs(phi) == 90 ? 0 :
92  // a * cos(beta)
93  _a / Math::hypot(real(1), _f1 * tand(phi));
94  }
95 
97  real tbeta = _f1 * tand(phi);
98  // b * sin(beta)
99  return _b * tbeta / Math::hypot(real(1), _f1 * tand(phi));
100  }
101 
103  { return _b * _ell.Ed( ParametricLatitude(phi) ); }
104 
106  real v = 1 - _e2 * Math::sq(sin(phi * Math::degree()));
107  return _a * (1 - _e2) / (v * sqrt(v));
108  }
109 
111  real v = 1 - _e2 * Math::sq(sin(phi * Math::degree()));
112  return _a / sqrt(v);
113  }
114 
116  const {
117  real
118  alpha = azi * Math::degree(),
119  v = 1 - _e2 * Math::sq(sin(phi * Math::degree()));
120  return _a / (sqrt(v) *
121  (Math::sq(cos(alpha)) * v / (1 - _e2) + Math::sq(sin(alpha))));
122  }
123 
124 } // namespace GeographicLib