AzimuthalEquidistant.cpp

Go to the documentation of this file.
00001 /**
00002  * \file AzimuthalEquidistant.cpp
00003  * \brief Implementation for GeographicLib::AzimuthalEquidistant class
00004  *
00005  * Copyright (c) Charles Karney (2009, 2010) <charles@karney.com>
00006  * and licensed under the LGPL.  For more information, see
00007  * http://geographiclib.sourceforge.net/
00008  **********************************************************************/
00009 
00010 #include "GeographicLib/AzimuthalEquidistant.hpp"
00011 
00012 #define GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_CPP "$Id: AzimuthalEquidistant.cpp 6921 2010-12-31 14:34:50Z karney $"
00013 
00014 RCSID_DECL(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_CPP)
00015 RCSID_DECL(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP)
00016 
00017 namespace GeographicLib {
00018 
00019   using namespace std;
00020 
00021   const Math::real AzimuthalEquidistant::eps =
00022     real(0.01) * sqrt(numeric_limits<real>::min());
00023 
00024   void AzimuthalEquidistant::Forward(real lat0, real lon0, real lat, real lon,
00025                                      real& x, real& y, real& azi, real& rk)
00026     const throw() {
00027     real sig, s, azi0, m;
00028     sig = _earth.Inverse(lat0, lon0, lat, lon, s, azi0, azi, m);
00029     azi0 *= Math::degree<real>();
00030     x = s * sin(azi0);
00031     y = s * cos(azi0);
00032     rk = !(sig <= eps) ? m / s : 1;
00033   }
00034 
00035   void AzimuthalEquidistant::Reverse(real lat0, real lon0, real x, real y,
00036                                      real& lat, real& lon, real& azi, real& rk)
00037     const throw() {
00038     real
00039       azi0 = atan2(x, y) / Math::degree<real>(),
00040       s = Math::hypot(x, y);
00041     real sig, m;
00042     sig = _earth.Direct(lat0, lon0, azi0, s, lat, lon, azi, m);
00043     rk = !(sig <= eps) ? m / s : 1;
00044   }
00045 
00046 } // namespace GeographicLib