00001 /** 00002 * \file AzimuthalEquidistant.hpp 00003 * \brief Header 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 #if !defined(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP) 00011 #define GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP "$Id: AzimuthalEquidistant.hpp 6867 2010-09-11 13:04:26Z karney $" 00012 00013 #include "GeographicLib/Geodesic.hpp" 00014 #include "GeographicLib/Constants.hpp" 00015 00016 namespace GeographicLib { 00017 00018 /** 00019 * \brief Azimuthal Equidistant Projection. 00020 * 00021 * Azimuthal equidistant projection centered at an arbitrary position on the 00022 * ellipsoid. For a point in projected space (\e x, \e y), the geodesic 00023 * distance from the center position is hypot(\e x, \e y) and the azimuth of 00024 * the geodesic from the center point is atan2(\e x, \e y). The Forward and 00025 * Reverse methods also return the azimuth \e azi of the geodesic at (\e x, 00026 * \e y) and reciprocal scale \e rk in the azimuthal direction which, 00027 * together with the basic properties of the projection, serve to specify 00028 * completely the local affine transformation between geographic and 00029 * projected coordinates. 00030 * 00031 * The conversions all take place using a Geodesic object (by default 00032 * Geodesic::WGS84). For more information on geodesics see \ref geodesic. 00033 **********************************************************************/ 00034 00035 class AzimuthalEquidistant { 00036 private: 00037 typedef Math::real real; 00038 const Geodesic _earth; 00039 static const real eps; 00040 public: 00041 00042 /** 00043 * Constructor for AzimuthalEquidistant. 00044 * 00045 * @param[in] earth the Geodesic object to use for geodesic calculations. 00046 * By default this uses the WGS84 ellipsoid. 00047 **********************************************************************/ 00048 explicit AzimuthalEquidistant(const Geodesic& earth = Geodesic::WGS84) 00049 throw() : _earth(earth) {} 00050 00051 /** 00052 * Forward projection, from geographic to azimuthal equidistant. 00053 * 00054 * @param[in] lat0 latitude of center point of projection (degrees). 00055 * @param[in] lon0 longitude of center point of projection (degrees). 00056 * @param[in] lat latitude of point (degrees). 00057 * @param[in] lon longitude of point (degrees). 00058 * @param[out] x easting of point (meters). 00059 * @param[out] y northing of point (meters). 00060 * @param[out] azi azimuth of geodesic at point (degrees). 00061 * @param[out] rk reciprocal of azimuthal scale at point. 00062 * 00063 * \e lat0 and \e lat should be in the range [-90, 90] and \e lon0 and \e 00064 * lon should be in the range [-180, 360]. The scale of the projection is 00065 * 1 in the "radial" direction, \e azi clockwise from true north, and is 00066 * 1/\e rk in the direction perpendicular to this. A call to Forward 00067 * followed by a call to Reverse will return the original (\e lat, \e lon) 00068 * (to within roundoff). 00069 **********************************************************************/ 00070 void Forward(real lat0, real lon0, real lat, real lon, 00071 real& x, real& y, real& azi, real& rk) const throw(); 00072 00073 /** 00074 * Reverse projection, from azimuthal equidistant to geographic. 00075 * 00076 * @param[in] lat0 latitude of center point of projection (degrees). 00077 * @param[in] lon0 longitude of center point of projection (degrees). 00078 * @param[in] x easting of point (meters). 00079 * @param[in] y northing of point (meters). 00080 * @param[out] lat latitude of point (degrees). 00081 * @param[out] lon longitude of point (degrees). 00082 * @param[out] azi azimuth of geodesic at point (degrees). 00083 * @param[out] rk reciprocal of azimuthal scale at point. 00084 * 00085 * \e lat0 should be in the range [-90, 90] and \e lon0 should be in the 00086 * range [-180, 360]. \e lat will be in the range [-90, 90] and \e lon 00087 * will be in the range [-180, 180). The scale of the projection is 1 in 00088 * the "radial" direction, \e azi clockwise from true north, and is 1/\e rk 00089 * in the direction perpendicular to this. A call to Reverse followed by a 00090 * call to Forward will return the original (\e x, \e y) (to roundoff) only 00091 * if the geodesic to (\e x, \e y) is a shortest path. 00092 **********************************************************************/ 00093 void Reverse(real lat0, real lon0, real x, real y, 00094 real& lat, real& lon, real& azi, real& rk) const throw(); 00095 00096 /** 00097 * AzimuthalEquidistant::Forward without returning the azimuth and scale. 00098 **********************************************************************/ 00099 void Forward(real lat0, real lon0, real lat, real lon, 00100 real& x, real& y) const throw() { 00101 real azi, rk; 00102 Forward(lat0, lon0, lat, lon, x, y, azi, rk); 00103 } 00104 00105 /** 00106 * AzimuthalEquidistant::Reverse without returning the azimuth and scale. 00107 **********************************************************************/ 00108 void Reverse(real lat0, real lon0, real x, real y, 00109 real& lat, real& lon) const throw() { 00110 real azi, rk; 00111 Reverse(lat0, lon0, x, y, lat, lon, azi, rk); 00112 } 00113 00114 /** \name Inspector functions 00115 **********************************************************************/ 00116 ///@{ 00117 /** 00118 * @return \e a the equatorial radius of the ellipsoid (meters). This is 00119 * the value inherited from the Geodesic object used in the constructor. 00120 **********************************************************************/ 00121 Math::real MajorRadius() const throw() { return _earth.MajorRadius(); } 00122 00123 /** 00124 * @return \e r the inverse flattening of the ellipsoid. This is the 00125 * value inherited from the Geodesic object used in the constructor. A 00126 * value of 0 is returned for a sphere (infinite inverse flattening). 00127 **********************************************************************/ 00128 Math::real InverseFlattening() const throw() 00129 { return _earth.InverseFlattening(); } 00130 ///@} 00131 }; 00132 00133 } // namespace GeographicLib 00134 00135 #endif