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