Loading...
Searching...
No Matches
Ellipsoid.cpp
Go to the documentation of this file.
/**
* \file Ellipsoid.cpp
* \brief Implementation for GeographicLib::Ellipsoid class
*
* Copyright (c) Charles Karney (2012-2023) <karney@alum.mit.edu> and licensed
* under the MIT/X11 License. For more information, see
* https://geographiclib.sourceforge.io/
**********************************************************************/
#include <GeographicLib/Ellipsoid.hpp>
namespace GeographicLib {
using namespace std;
/// \cond SKIP
Ellipsoid::Ellipsoid(real a, real f)
: stol_(real(0.01) * sqrt(numeric_limits<real>::epsilon()))
, _a(a)
, _f(f)
, _b(_a * (1 - _f))
, _e2(_f * (2 - _f))
, _e12(_e2 / (1 - _e2))
, _n(_f / (2 - _f))
, _aux(_a, _f)
, _rm(_aux.RectifyingRadius(true))
, _c2(_aux.AuthalicRadiusSquared(true))
{}
/// \endcond
const Ellipsoid& Ellipsoid::WGS84() {
static const Ellipsoid wgs84(Constants::WGS84_a(), Constants::WGS84_f());
return wgs84;
}
Math::real Ellipsoid::QuarterMeridian() const
{ return Math::pi()/2 * _rm; }
Math::real Ellipsoid::Area() const
{ return 4 * Math::pi() * _c2; }
Math::real Ellipsoid::ParametricLatitude(real phi) const {
return _aux.Convert(AuxLatitude::PHI, AuxLatitude::BETA,
Math::LatFix(phi), true);
}
Math::real Ellipsoid::InverseParametricLatitude(real beta) const {
return _aux.Convert(AuxLatitude::BETA, AuxLatitude::PHI,
Math::LatFix(beta), true);
}
Math::real Ellipsoid::GeocentricLatitude(real phi) const {
return _aux.Convert(AuxLatitude::PHI, AuxLatitude::THETA,
Math::LatFix(phi), true);
}
Math::real Ellipsoid::InverseGeocentricLatitude(real theta) const {
return _aux.Convert(AuxLatitude::THETA, AuxLatitude::PHI,
Math::LatFix(theta), true);
}
Math::real Ellipsoid::RectifyingLatitude(real phi) const {
return _aux.Convert(AuxLatitude::PHI, AuxLatitude::MU,
Math::LatFix(phi), true);
}
Math::real Ellipsoid::InverseRectifyingLatitude(real mu) const {
return _aux.Convert(AuxLatitude::MU, AuxLatitude::PHI,
Math::LatFix(mu), true);
}
Math::real Ellipsoid::AuthalicLatitude(real phi) const {
return _aux.Convert(AuxLatitude::PHI, AuxLatitude::XI,
Math::LatFix(phi), true);
}
Math::real Ellipsoid::InverseAuthalicLatitude(real xi) const {
return _aux.Convert(AuxLatitude::XI, AuxLatitude::PHI,
Math::LatFix(xi), true);
}
Math::real Ellipsoid::ConformalLatitude(real phi) const {
return _aux.Convert(AuxLatitude::PHI, AuxLatitude::CHI,
Math::LatFix(phi), true);
}
Math::real Ellipsoid::InverseConformalLatitude(real chi) const {
return _aux.Convert(AuxLatitude::CHI, AuxLatitude::PHI,
Math::LatFix(chi), true);
}
Math::real Ellipsoid::IsometricLatitude(real phi) const {
return _aux.Convert(AuxLatitude::PHI, AuxLatitude::CHI,
AuxAngle::degrees(Math::LatFix(phi)), true).lamd();
}
Math::real Ellipsoid::InverseIsometricLatitude(real psi) const {
return _aux.Convert(AuxLatitude::CHI, AuxLatitude::PHI,
AuxAngle::lamd(psi), true).degrees();
}
Math::real Ellipsoid::CircleRadius(real phi) const {
// a * cos(beta)
AuxAngle beta(_aux.Convert(AuxLatitude::PHI, AuxLatitude::BETA,
AuxAngle::degrees(Math::LatFix(phi)),
true).normalized());
return _a * beta.x();
}
Math::real Ellipsoid::CircleHeight(real phi) const {
// b * sin(beta)
AuxAngle beta(_aux.Convert(AuxLatitude::PHI, AuxLatitude::BETA,
AuxAngle::degrees(Math::LatFix(phi)),
true).normalized());
return _b * beta.y();
}
Math::real Ellipsoid::MeridianDistance(real phi) const {
return _rm * _aux.Convert(AuxLatitude::PHI, AuxLatitude::MU,
AuxAngle::degrees(Math::LatFix(phi)),
true).radians();
}
Math::real Ellipsoid::MeridionalCurvatureRadius(real phi) const {
real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
return _a * (1 - _e2) / (v * sqrt(v));
}
Math::real Ellipsoid::TransverseCurvatureRadius(real phi) const {
real v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
return _a / sqrt(v);
}
Math::real Ellipsoid::NormalCurvatureRadius(real phi, real azi) const {
real calp, salp,
v = 1 - _e2 * Math::sq(Math::sind(Math::LatFix(phi)));
Math::sincosd(azi, salp, calp);
return _a / (sqrt(v) * (Math::sq(calp) * v / (1 - _e2) + Math::sq(salp)));
}
} // namespace GeographicLib
Ellipsoid.hpp
Header for GeographicLib::Ellipsoid class.
real
GeographicLib::Math::real real
Definition Geod3Solve.cpp:25
GeographicLib::AuxAngle
An accurate representation of angles.
Definition AuxAngle.hpp:51
GeographicLib::AuxAngle::y
Math::real y() const
Definition AuxAngle.hpp:74
GeographicLib::AuxAngle::x
Math::real x() const
Definition AuxAngle.hpp:79
GeographicLib::AuxAngle::degrees
Math::real degrees() const
Definition AuxAngle.hpp:228
GeographicLib::AuxAngle::lamd
Math::real lamd() const
Definition AuxAngle.hpp:240
GeographicLib::AuxLatitude::XI
@ XI
Definition AuxLatitude.hpp:151
GeographicLib::AuxLatitude::BETA
@ BETA
Definition AuxLatitude.hpp:131
GeographicLib::AuxLatitude::MU
@ MU
Definition AuxLatitude.hpp:141
GeographicLib::AuxLatitude::THETA
@ THETA
Definition AuxLatitude.hpp:136
GeographicLib::AuxLatitude::CHI
@ CHI
Definition AuxLatitude.hpp:146
GeographicLib::AuxLatitude::PHI
@ PHI
Definition AuxLatitude.hpp:126
GeographicLib::Constants::WGS84_f
static T WGS84_f()
Definition Constants.hpp:118
GeographicLib::Constants::WGS84_a
static T WGS84_a()
Definition Constants.hpp:112
GeographicLib::Ellipsoid::Area
Math::real Area() const
Definition Ellipsoid.cpp:39
GeographicLib::Ellipsoid::RectifyingLatitude
Math::real RectifyingLatitude(real phi) const
Definition Ellipsoid.cpp:62
GeographicLib::Ellipsoid::IsometricLatitude
Math::real IsometricLatitude(real phi) const
Definition Ellipsoid.cpp:92
GeographicLib::Ellipsoid::CircleHeight
Math::real CircleHeight(real phi) const
Definition Ellipsoid.cpp:110
GeographicLib::Ellipsoid::AuthalicLatitude
Math::real AuthalicLatitude(real phi) const
Definition Ellipsoid.cpp:72
GeographicLib::Ellipsoid::NormalCurvatureRadius
Math::real NormalCurvatureRadius(real phi, real azi) const
Definition Ellipsoid.cpp:134
GeographicLib::Ellipsoid::QuarterMeridian
Math::real QuarterMeridian() const
Definition Ellipsoid.cpp:36
GeographicLib::Ellipsoid::Ellipsoid
Ellipsoid(real a, real f)
GeographicLib::Ellipsoid::CircleRadius
Math::real CircleRadius(real phi) const
Definition Ellipsoid.cpp:102
GeographicLib::Ellipsoid::ConformalLatitude
Math::real ConformalLatitude(real phi) const
Definition Ellipsoid.cpp:82
GeographicLib::Ellipsoid::InverseIsometricLatitude
Math::real InverseIsometricLatitude(real psi) const
Definition Ellipsoid.cpp:97
GeographicLib::Ellipsoid::InverseParametricLatitude
Math::real InverseParametricLatitude(real beta) const
Definition Ellipsoid.cpp:47
GeographicLib::Ellipsoid::InverseRectifyingLatitude
Math::real InverseRectifyingLatitude(real mu) const
Definition Ellipsoid.cpp:67
GeographicLib::Ellipsoid::WGS84
static const Ellipsoid & WGS84()
Definition Ellipsoid.cpp:31
GeographicLib::Ellipsoid::MeridionalCurvatureRadius
Math::real MeridionalCurvatureRadius(real phi) const
Definition Ellipsoid.cpp:124
GeographicLib::Ellipsoid::InverseAuthalicLatitude
Math::real InverseAuthalicLatitude(real xi) const
Definition Ellipsoid.cpp:77
GeographicLib::Ellipsoid::InverseConformalLatitude
Math::real InverseConformalLatitude(real chi) const
Definition Ellipsoid.cpp:87
GeographicLib::Ellipsoid::TransverseCurvatureRadius
Math::real TransverseCurvatureRadius(real phi) const
Definition Ellipsoid.cpp:129
GeographicLib::Ellipsoid::ParametricLatitude
Math::real ParametricLatitude(real phi) const
Definition Ellipsoid.cpp:42
GeographicLib::Ellipsoid::GeocentricLatitude
Math::real GeocentricLatitude(real phi) const
Definition Ellipsoid.cpp:52
GeographicLib::Ellipsoid::MeridianDistance
Math::real MeridianDistance(real phi) const
Definition Ellipsoid.cpp:118
GeographicLib::Ellipsoid::InverseGeocentricLatitude
Math::real InverseGeocentricLatitude(real theta) const
Definition Ellipsoid.cpp:57
GeographicLib::Math::LatFix
static T LatFix(T x)
Definition Math.hpp:303
GeographicLib::Math::sincosd
static void sincosd(T x, T &sinx, T &cosx)
Definition Math.cpp:104
GeographicLib::Math::sq
static T sq(T x)
Definition Math.hpp:209
GeographicLib::Math::sind
static T sind(T x)
Definition Math.cpp:172
GeographicLib::Math::pi
static T pi()
Definition Math.hpp:187
GeographicLib::Math::real
double real
Definition Math.hpp:115
GeographicLib
Namespace for GeographicLib.
Definition Accumulator.cpp:12