GeographicLib  1.38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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