GeographicLib  1.43
AzimuthalEquidistant.cpp
Go to the documentation of this file.
1 /**
2  * \file AzimuthalEquidistant.cpp
3  * \brief Implementation for GeographicLib::AzimuthalEquidistant class
4  *
5  * Copyright (c) Charles Karney (2009-2011) <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 
17  : eps_(real(0.01) * sqrt(numeric_limits<real>::min()))
18  , _earth(earth) {}
19 
20  void AzimuthalEquidistant::Forward(real lat0, real lon0, real lat, real lon,
21  real& x, real& y, real& azi, real& rk)
22  const {
23  real sig, s, azi0, m;
24  sig = _earth.Inverse(lat0, lon0, lat, lon, s, azi0, azi, m);
25  azi0 *= Math::degree();
26  x = s * sin(azi0);
27  y = s * cos(azi0);
28  rk = !(sig <= eps_) ? m / s : 1;
29  }
30 
31  void AzimuthalEquidistant::Reverse(real lat0, real lon0, real x, real y,
32  real& lat, real& lon, real& azi, real& rk)
33  const {
34  real
35  azi0 = atan2(x, y) / Math::degree(),
36  s = Math::hypot(x, y);
37  real sig, m;
38  sig = _earth.Direct(lat0, lon0, azi0, s, lat, lon, azi, m);
39  rk = !(sig <= eps_) ? m / s : 1;
40  }
41 
42 } // namespace GeographicLib
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const
Definition: Geodesic.hpp:379
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &m12, real &M12, real &M21, real &S12) const
Definition: Geodesic.hpp:679
void Reverse(real lat0, real lon0, real x, real y, real &lat, real &lon, real &azi, real &rk) const
AzimuthalEquidistant(const Geodesic &earth=Geodesic::WGS84())
static T hypot(T x, T y)
Definition: Math.hpp:255
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
static T degree()
Definition: Math.hpp:228
void Forward(real lat0, real lon0, real lat, real lon, real &x, real &y, real &azi, real &rk) const
Header for GeographicLib::AzimuthalEquidistant class.
Geodesic calculations
Definition: Geodesic.hpp:171