GeographicLib 2.1.2
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-2022) <charles@karney.com> and licensed
6 * under the MIT/X11 License. For more information, see
7 * https://geographiclib.sourceforge.io/
8 **********************************************************************/
9
11
12#if defined(_MSC_VER)
13// Squelch warnings about enum-float expressions
14# pragma warning (disable: 5055)
15#endif
16
17namespace GeographicLib {
18
19 using namespace std;
20
21 Ellipsoid::Ellipsoid(real a, real f)
22 : stol_(real(0.01) * sqrt(numeric_limits<real>::epsilon()))
23 , _a(a)
24 , _f(f)
25 , _f1(1 - _f)
26 , _f12(Math::sq(_f1))
27 , _e2(_f * (2 - _f))
28 , _es((_f < 0 ? -1 : 1) * sqrt(fabs(_e2)))
29 , _e12(_e2 / (1 - _e2))
30 , _n(_f / (2 - _f))
31 , _b(_a * _f1)
32 , _tm(_a, _f, real(1))
33 , _ell(-_e12)
34 , _au(_a, _f, real(0), real(1), real(0), real(1), real(1))
35 {}
36
38 static const Ellipsoid wgs84(Constants::WGS84_a(), Constants::WGS84_f());
39 return wgs84;
40 }
41
43 { return _b * _ell.E(); }
44
46 return 4 * Math::pi() *
47 ((Math::sq(_a) + Math::sq(_b) *
48 (_e2 == 0 ? 1 :
49 (_e2 > 0 ? atanh(sqrt(_e2)) : atan(sqrt(-_e2))) /
50 sqrt(fabs(_e2))))/2);
51 }
52
54 { return Math::atand(_f1 * Math::tand(Math::LatFix(phi))); }
55
57 { return Math::atand(Math::tand(Math::LatFix(beta)) / _f1); }
58
60 { return Math::atand(_f12 * Math::tand(Math::LatFix(phi))); }
61
63 { return Math::atand(Math::tand(Math::LatFix(theta)) / _f12); }
64
66 return fabs(phi) == Math::qd ? phi:
68 }
69
71 if (fabs(mu) == Math::qd)
72 return mu;
73 return InverseParametricLatitude(_ell.Einv(mu * _ell.E() / Math::qd) /
74 Math::degree());
75 }
76
78 { return Math::atand(_au.txif(Math::tand(Math::LatFix(phi)))); }
79
81 { return Math::atand(_au.tphif(Math::tand(Math::LatFix(xi)))); }
82
84 { return Math::atand(Math::taupf(Math::tand(Math::LatFix(phi)), _es)); }
85
87 { return Math::atand(Math::tauf(Math::tand(Math::LatFix(chi)), _es)); }
88
90 { return asinh(Math::taupf(Math::tand(Math::LatFix(phi)), _es)) /
91 Math::degree(); }
92
94 { return Math::atand(Math::tauf(sinh(psi * Math::degree()), _es)); }
95
97 return fabs(phi) == Math::qd ? 0 :
98 // a * cos(beta)
99 _a / hypot(real(1), _f1 * Math::tand(Math::LatFix(phi)));
100 }
101
103 real tbeta = _f1 * Math::tand(phi);
104 // b * sin(beta)
105 return _b * tbeta / hypot(real(1),
106 _f1 * Math::tand(Math::LatFix(phi)));
107 }
108
110 { return _b * _ell.Ed( ParametricLatitude(phi) ); }
111
113 real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
114 return _a * (1 - _e2) / (v * sqrt(v));
115 }
116
118 real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
119 return _a / sqrt(v);
120 }
121
123 real calp, salp,
124 v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
125 Math::sincosd(azi, salp, calp);
126 return _a / (sqrt(v) * (Math::sq(calp) * v / (1 - _e2) + Math::sq(salp)));
127 }
128
129} // namespace GeographicLib
Header for GeographicLib::Ellipsoid class.
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:39
Math::real Area() const
Definition: Ellipsoid.cpp:45
Math::real RectifyingLatitude(real phi) const
Definition: Ellipsoid.cpp:65
Math::real IsometricLatitude(real phi) const
Definition: Ellipsoid.cpp:89
Math::real CircleHeight(real phi) const
Definition: Ellipsoid.cpp:102
Math::real AuthalicLatitude(real phi) const
Definition: Ellipsoid.cpp:77
Math::real NormalCurvatureRadius(real phi, real azi) const
Definition: Ellipsoid.cpp:122
Math::real QuarterMeridian() const
Definition: Ellipsoid.cpp:42
Ellipsoid(real a, real f)
Definition: Ellipsoid.cpp:21
Math::real CircleRadius(real phi) const
Definition: Ellipsoid.cpp:96
Math::real ConformalLatitude(real phi) const
Definition: Ellipsoid.cpp:83
Math::real InverseIsometricLatitude(real psi) const
Definition: Ellipsoid.cpp:93
Math::real InverseParametricLatitude(real beta) const
Definition: Ellipsoid.cpp:56
Math::real InverseRectifyingLatitude(real mu) const
Definition: Ellipsoid.cpp:70
static const Ellipsoid & WGS84()
Definition: Ellipsoid.cpp:37
Math::real MeridionalCurvatureRadius(real phi) const
Definition: Ellipsoid.cpp:112
Math::real InverseAuthalicLatitude(real xi) const
Definition: Ellipsoid.cpp:80
Math::real InverseConformalLatitude(real chi) const
Definition: Ellipsoid.cpp:86
Math::real TransverseCurvatureRadius(real phi) const
Definition: Ellipsoid.cpp:117
Math::real ParametricLatitude(real phi) const
Definition: Ellipsoid.cpp:53
Math::real GeocentricLatitude(real phi) const
Definition: Ellipsoid.cpp:59
Math::real MeridianDistance(real phi) const
Definition: Ellipsoid.cpp:109
Math::real InverseGeocentricLatitude(real theta) const
Definition: Ellipsoid.cpp:62
Math::real Einv(real x) const
Math::real Ed(real ang) const
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:76
static T degree()
Definition: Math.hpp:200
static T tand(T x)
Definition: Math.cpp:172
static T LatFix(T x)
Definition: Math.hpp:300
static void sincosd(T x, T &sinx, T &cosx)
Definition: Math.cpp:106
static T sq(T x)
Definition: Math.hpp:212
static T sind(T x)
Definition: Math.cpp:148
static T tauf(T taup, T es)
Definition: Math.cpp:219
static T atand(T x)
Definition: Math.cpp:202
static T taupf(T tau, T es)
Definition: Math.cpp:209
static T pi()
Definition: Math.hpp:190
@ qd
degrees per quarter turn
Definition: Math.hpp:141
Namespace for GeographicLib.
Definition: Accumulator.cpp:12