GeographicLib 2.4

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