AzimuthalEquidistant.hpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * \file AzimuthalEquidistant.hpp
  3. * \brief Header for GeographicLib::AzimuthalEquidistant class
  4. *
  5. * Copyright (c) Charles Karney (2009-2020) <charles@karney.com> and licensed
  6. * under the MIT/X11 License. For more information, see
  7. * https://geographiclib.sourceforge.io/
  8. **********************************************************************/
  9. #if !defined(GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP)
  10. #define GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP 1
  11. #include <GeographicLib/Geodesic.hpp>
  12. #include <GeographicLib/Constants.hpp>
  13. namespace GeographicLib {
  14. /**
  15. * \brief Azimuthal equidistant projection
  16. *
  17. * Azimuthal equidistant projection centered at an arbitrary position on the
  18. * ellipsoid. For a point in projected space (\e x, \e y), the geodesic
  19. * distance from the center position is hypot(\e x, \e y) and the azimuth of
  20. * the geodesic from the center point is atan2(\e x, \e y). The Forward and
  21. * Reverse methods also return the azimuth \e azi of the geodesic at (\e x,
  22. * \e y) and reciprocal scale \e rk in the azimuthal direction which,
  23. * together with the basic properties of the projection, serve to specify
  24. * completely the local affine transformation between geographic and
  25. * projected coordinates.
  26. *
  27. * The conversions all take place using a Geodesic object (by default
  28. * Geodesic::WGS84()). For more information on geodesics see \ref geodesic.
  29. *
  30. * Example of use:
  31. * \include example-AzimuthalEquidistant.cpp
  32. *
  33. * <a href="GeodesicProj.1.html">GeodesicProj</a> is a command-line utility
  34. * providing access to the functionality of AzimuthalEquidistant, Gnomonic,
  35. * and CassiniSoldner.
  36. **********************************************************************/
  37. class GEOGRAPHICLIB_EXPORT AzimuthalEquidistant {
  38. private:
  39. typedef Math::real real;
  40. real eps_;
  41. Geodesic _earth;
  42. public:
  43. /**
  44. * Constructor for AzimuthalEquidistant.
  45. *
  46. * @param[in] earth the Geodesic object to use for geodesic calculations.
  47. * By default this uses the WGS84 ellipsoid.
  48. **********************************************************************/
  49. explicit AzimuthalEquidistant(const Geodesic& earth = Geodesic::WGS84());
  50. /**
  51. * Forward projection, from geographic to azimuthal equidistant.
  52. *
  53. * @param[in] lat0 latitude of center point of projection (degrees).
  54. * @param[in] lon0 longitude of center point of projection (degrees).
  55. * @param[in] lat latitude of point (degrees).
  56. * @param[in] lon longitude of point (degrees).
  57. * @param[out] x easting of point (meters).
  58. * @param[out] y northing of point (meters).
  59. * @param[out] azi azimuth of geodesic at point (degrees).
  60. * @param[out] rk reciprocal of azimuthal scale at point.
  61. *
  62. * \e lat0 and \e lat should be in the range [&minus;90&deg;, 90&deg;].
  63. * The scale of the projection is 1 in the "radial" direction, \e azi
  64. * clockwise from true north, and is 1/\e rk in the direction perpendicular
  65. * to this. A call to Forward followed by a call to Reverse will return
  66. * the original (\e lat, \e lon) (to within roundoff).
  67. **********************************************************************/
  68. void Forward(real lat0, real lon0, real lat, real lon,
  69. real& x, real& y, real& azi, real& rk) const;
  70. /**
  71. * Reverse projection, from azimuthal equidistant to geographic.
  72. *
  73. * @param[in] lat0 latitude of center point of projection (degrees).
  74. * @param[in] lon0 longitude of center point of projection (degrees).
  75. * @param[in] x easting of point (meters).
  76. * @param[in] y northing of point (meters).
  77. * @param[out] lat latitude of point (degrees).
  78. * @param[out] lon longitude of point (degrees).
  79. * @param[out] azi azimuth of geodesic at point (degrees).
  80. * @param[out] rk reciprocal of azimuthal scale at point.
  81. *
  82. * \e lat0 should be in the range [&minus;90&deg;, 90&deg;]. \e lat will
  83. * be in the range [&minus;90&deg;, 90&deg;] and \e lon will be in the
  84. * range [&minus;180&deg;, 180&deg;]. The scale of the projection is 1 in
  85. * the "radial" direction, \e azi clockwise from true north, and is 1/\e rk
  86. * in the direction perpendicular to this. A call to Reverse followed by a
  87. * call to Forward will return the original (\e x, \e y) (to roundoff) only
  88. * if the geodesic to (\e x, \e y) is a shortest path.
  89. **********************************************************************/
  90. void Reverse(real lat0, real lon0, real x, real y,
  91. real& lat, real& lon, real& azi, real& rk) const;
  92. /**
  93. * AzimuthalEquidistant::Forward without returning the azimuth and scale.
  94. **********************************************************************/
  95. void Forward(real lat0, real lon0, real lat, real lon,
  96. real& x, real& y) const {
  97. real azi, rk;
  98. Forward(lat0, lon0, lat, lon, x, y, azi, rk);
  99. }
  100. /**
  101. * AzimuthalEquidistant::Reverse without returning the azimuth and scale.
  102. **********************************************************************/
  103. void Reverse(real lat0, real lon0, real x, real y,
  104. real& lat, real& lon) const {
  105. real azi, rk;
  106. Reverse(lat0, lon0, x, y, lat, lon, azi, rk);
  107. }
  108. /** \name Inspector functions
  109. **********************************************************************/
  110. ///@{
  111. /**
  112. * @return \e a the equatorial radius of the ellipsoid (meters). This is
  113. * the value inherited from the Geodesic object used in the constructor.
  114. **********************************************************************/
  115. Math::real EquatorialRadius() const { return _earth.EquatorialRadius(); }
  116. /**
  117. * @return \e f the flattening of the ellipsoid. This is the value
  118. * inherited from the Geodesic object used in the constructor.
  119. **********************************************************************/
  120. Math::real Flattening() const { return _earth.Flattening(); }
  121. /**
  122. * \deprecated An old name for EquatorialRadius().
  123. **********************************************************************/
  124. GEOGRAPHICLIB_DEPRECATED("Use EquatorialRadius()")
  125. Math::real MajorRadius() const { return EquatorialRadius(); }
  126. ///@}
  127. };
  128. } // namespace GeographicLib
  129. #endif // GEOGRAPHICLIB_AZIMUTHALEQUIDISTANT_HPP