GeographicLib 2.3
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-2023) <karney@alum.mit.edu> 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 /// \cond SKIP
23 : stol_(real(0.01) * sqrt(numeric_limits<real>::epsilon()))
24 , _a(a)
25 , _f(f)
26 , _b(_a * (1 - _f))
27 , _e2(_f * (2 - _f))
28 , _e12(_e2 / (1 - _e2))
29 , _n(_f / (2 - _f))
30 , _aux(_a, _f)
31 , _rm(_aux.RectifyingRadius(true))
32 , _c2(_aux.AuthalicRadiusSquared(true))
33 {}
34 /// \endcond
35
36 const Ellipsoid& Ellipsoid::WGS84() {
37 static const Ellipsoid wgs84(Constants::WGS84_a(), Constants::WGS84_f());
38 return wgs84;
39 }
40
41 Math::real Ellipsoid::QuarterMeridian() const
42 { return Math::pi()/2 * _rm; }
43
44 Math::real Ellipsoid::Area() const
45 { return 4 * Math::pi() * _c2; }
46
47 Math::real Ellipsoid::ParametricLatitude(real phi) const {
48 return _aux.Convert(AuxLatitude::PHI, AuxLatitude::BETA,
49 Math::LatFix(phi), true);
50 }
51
52 Math::real Ellipsoid::InverseParametricLatitude(real beta) const {
53 return _aux.Convert(AuxLatitude::BETA, AuxLatitude::PHI,
54 Math::LatFix(beta), true);
55 }
56
57 Math::real Ellipsoid::GeocentricLatitude(real phi) const {
58 return _aux.Convert(AuxLatitude::PHI, AuxLatitude::THETA,
59 Math::LatFix(phi), true);
60 }
61
62 Math::real Ellipsoid::InverseGeocentricLatitude(real theta) const {
63 return _aux.Convert(AuxLatitude::THETA, AuxLatitude::PHI,
64 Math::LatFix(theta), true);
65 }
66
67 Math::real Ellipsoid::RectifyingLatitude(real phi) const {
68 return _aux.Convert(AuxLatitude::PHI, AuxLatitude::MU,
69 Math::LatFix(phi), true);
70 }
71
72 Math::real Ellipsoid::InverseRectifyingLatitude(real mu) const {
73 return _aux.Convert(AuxLatitude::MU, AuxLatitude::PHI,
74 Math::LatFix(mu), true);
75 }
76
77 Math::real Ellipsoid::AuthalicLatitude(real phi) const {
78 return _aux.Convert(AuxLatitude::PHI, AuxLatitude::XI,
79 Math::LatFix(phi), true);
80 }
81
82 Math::real Ellipsoid::InverseAuthalicLatitude(real xi) const {
83 return _aux.Convert(AuxLatitude::XI, AuxLatitude::PHI,
84 Math::LatFix(xi), true);
85 }
86
87 Math::real Ellipsoid::ConformalLatitude(real phi) const {
88 return _aux.Convert(AuxLatitude::PHI, AuxLatitude::CHI,
89 Math::LatFix(phi), true);
90 }
91
92 Math::real Ellipsoid::InverseConformalLatitude(real chi) const {
93 return _aux.Convert(AuxLatitude::CHI, AuxLatitude::PHI,
94 Math::LatFix(chi), true);
95 }
96
97 Math::real Ellipsoid::IsometricLatitude(real phi) const {
98 return _aux.Convert(AuxLatitude::PHI, AuxLatitude::CHI,
99 AuxAngle::degrees(Math::LatFix(phi)), true).lamd();
100 }
101
102 Math::real Ellipsoid::InverseIsometricLatitude(real psi) const {
103 return _aux.Convert(AuxLatitude::CHI, AuxLatitude::PHI,
104 AuxAngle::lamd(psi), true).degrees();
105 }
106
107 Math::real Ellipsoid::CircleRadius(real phi) const {
108 // a * cos(beta)
109 AuxAngle beta(_aux.Convert(AuxLatitude::PHI, AuxLatitude::BETA,
110 AuxAngle::degrees(Math::LatFix(phi)),
111 true).normalized());
112 return _a * beta.x();
113 }
114
115 Math::real Ellipsoid::CircleHeight(real phi) const {
116 // b * sin(beta)
117 AuxAngle beta(_aux.Convert(AuxLatitude::PHI, AuxLatitude::BETA,
118 AuxAngle::degrees(Math::LatFix(phi)),
119 true).normalized());
120 return _b * beta.y();
121 }
122
123 Math::real Ellipsoid::MeridianDistance(real phi) const {
124 return _rm * _aux.Convert(AuxLatitude::PHI, AuxLatitude::MU,
125 AuxAngle::degrees(Math::LatFix(phi)),
126 true).radians();
127 }
128
129 Math::real Ellipsoid::MeridionalCurvatureRadius(real phi) const {
130 real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
131 return _a * (1 - _e2) / (v * sqrt(v));
132 }
133
134 Math::real Ellipsoid::TransverseCurvatureRadius(real phi) const {
135 real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
136 return _a / sqrt(v);
137 }
138
139 Math::real Ellipsoid::NormalCurvatureRadius(real phi, real azi) const {
140 real calp, salp,
141 v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
142 Math::sincosd(azi, salp, calp);
143 return _a / (sqrt(v) * (Math::sq(calp) * v / (1 - _e2) + Math::sq(salp)));
144 }
145
146} // namespace GeographicLib
Header for GeographicLib::Ellipsoid class.
GeographicLib::Math::real real
Definition: GeodSolve.cpp:29
An accurate representation of angles.
Definition: AuxAngle.hpp:47
Math::real y() const
Definition: AuxAngle.hpp:70
Math::real x() const
Definition: AuxAngle.hpp:75
Properties of an ellipsoid.
Definition: Ellipsoid.hpp:31
Ellipsoid(real a, real f)
Namespace for GeographicLib.
Definition: Accumulator.cpp:12