GeographicLib  1.35
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 
16  const Math::real AzimuthalEquidistant::eps_ =
17  real(0.01) * sqrt(numeric_limits<real>::min());
18 
19  void AzimuthalEquidistant::Forward(real lat0, real lon0, real lat, real lon,
20  real& x, real& y, real& azi, real& rk)
21  const throw() {
22  real sig, s, azi0, m;
23  sig = _earth.Inverse(lat0, lon0, lat, lon, s, azi0, azi, m);
24  azi0 *= Math::degree<real>();
25  x = s * sin(azi0);
26  y = s * cos(azi0);
27  rk = !(sig <= eps_) ? m / s : 1;
28  }
29 
30  void AzimuthalEquidistant::Reverse(real lat0, real lon0, real x, real y,
31  real& lat, real& lon, real& azi, real& rk)
32  const throw() {
33  real
34  azi0 = atan2(x, y) / Math::degree<real>(),
35  s = Math::hypot(x, y);
36  real sig, m;
37  sig = _earth.Direct(lat0, lon0, azi0, s, lat, lon, azi, m);
38  rk = !(sig <= eps_) ? m / s : 1;
39  }
40 
41 } // namespace GeographicLib
GeographicLib::Math::real real
Definition: GeodSolve.cpp:40
void Reverse(real lat0, real lon0, real x, real y, real &lat, real &lon, real &azi, real &rk) const
static T hypot(T x, T y)
Definition: Math.hpp:165
void Forward(real lat0, real lon0, real lat, real lon, real &x, real &y, real &azi, real &rk) const
Header for GeographicLib::AzimuthalEquidistant class.