Geodesic calculations More...
#include <GeographicLib/Geodesic.hpp>
Public Member Functions | |
Geodesic (real a, real r) | |
Math::real | Direct (real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2, real &m12, bool arcmode=false) const throw () |
Math::real | Inverse (real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &m12) const throw () |
GeodesicLine | Line (real lat1, real lon1, real azi1) const throw () |
Math::real | MajorRadius () const throw () |
Math::real | InverseFlattening () const throw () |
Static Public Attributes | |
static const Geodesic | WGS84 |
Friends | |
class | GeodesicLine |
Geodesic calculations
The shortest path between two points on a ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic. Its length is s12 and the geodesic from point 1 to point 2 has azimuths azi1 and azi2 at the two end points. (The azimuth is the heading measured clockwise from north. azi2 is the "forward" azimuth, i.e., the heading that takes you beyond point 2 not back to point 1.)
If we fix the first point and increase s12 by ds12, then the second point is displaced ds12 in the direction azi2. Similarly we increase azi1 by dazi1 (radians), the the second point is displaced m12 dazi1 in the direction azi2 + 90o. The quantity m12 is called the "reduced length" and is symmetric under interchange of the two points. On a flat surface, he have m12 = s12. The ratio s12/m12 gives the azimuthal scale for an azimuthal equidistant projection.
Given lat1, lon1, azi1, and s12, we can determine lat2, lon2, azi2, m12. This is the direct geodesic problem. (If s12 is sufficiently large that the geodesic wraps more than halfway around the earth, there will be another geodesic between the points with a smaller s12.)
Given lat1, lon1, lat2, and lon2, we can determine azi1, azi2, s12, m12. This is the inverse geodesic problem. Usually, the solution to the inverse problem is unique. In cases where there are muliple solutions (all with the same s12, of course), all the solutions can be easily generated once a particular solution is provided.
As an alternative to using distance to measure s12, the class can also use the arc length a12 (in degrees) on the auxiliary sphere. This is a mathematical construct used in solving the geodesic problems. However, an arc length in excess of 180o indicates that the geodesic is not a shortest path. In addition, the arc length between an equatorial crossing and the next extremum of latitude for a geodesic is 90o.
The calculations are accurate to better than 15 nm. (See Accuracy of geodesic calculation for details.)
For more information on geodesics see Geodesics on the Ellipsoid.
Definition at line 71 of file Geodesic.hpp.
GeographicLib::Geodesic::Geodesic | ( | real | a, | |
real | r | |||
) |
Constructor for a ellipsoid with equatorial radius a (meters) and reciprocal flattening r. Setting r = 0 implies r = inf or flattening = 0 (i.e., a sphere). Negative r indicates a prolate ellipsoid. An exception is thrown if a is not positive.
Definition at line 49 of file Geodesic.cpp.
Math::real GeographicLib::Geodesic::Direct | ( | real | lat1, | |
real | lon1, | |||
real | azi1, | |||
real | s12, | |||
real & | lat2, | |||
real & | lon2, | |||
real & | azi2, | |||
real & | m12, | |||
bool | arcmode = false | |||
) | const throw () |
Perform the direct geodesic calculation. Given a latitude, lat1, longitude, lon1, and azimuth azi1 (degrees) for point 1 and a range, s12 (meters) from point 1 to point 2, return the latitude, lat2, longitude, lon2, and forward azimuth, azi2 (degrees) for point 2 and the reduced length m12 (meters). If arcmode (default false) is set to true, s12 is interpreted as the arc length a12 (degrees) on the auxiliary sphere. An arc length greater that 180 degrees results in a geodesic which is not a shortest path. For a prolate ellipsoid, an additional condition is necessary for a shortest path: the longitudinal extent must not exceed of 180 degrees. Returned value is the arc length a12 (degrees) if arcmode is false, otherwise it is the distance s12 (meters)
Definition at line 87 of file Geodesic.cpp.
References GeographicLib::GeodesicLine::Position().
Math::real GeographicLib::Geodesic::Inverse | ( | real | lat1, | |
real | lon1, | |||
real | lat2, | |||
real | lon2, | |||
real & | s12, | |||
real & | azi1, | |||
real & | azi2, | |||
real & | m12 | |||
) | const throw () |
Perform the inverse geodesic calculation. Given a latitude, lat1, longitude, lon1, for point 1 and a latitude, lat2, longitude, lon2, for point 2 (all in degrees), return the geodesic distance, s12 (meters), the forward azimuths, azi1 and azi2 (degrees) at points 1 and 2, and the reduced length m12 (meters). Returned value is the arc length a12 (degrees) on the auxiliary sphere. The routine uses an iterative method. If the method fails to converge, the negative of the distances (s12, m12, and a12) and reverse of the azimuths are returned. This is not expected to happen with ellipsoidal models of the earth. Please report all cases where this occurs.
Definition at line 94 of file Geodesic.cpp.
References GeographicLib::Constants::degree(), and GeographicLib::Constants::pi().
GeodesicLine GeographicLib::Geodesic::Line | ( | real | lat1, | |
real | lon1, | |||
real | azi1 | |||
) | const throw () |
Set up to do a series of ranges. This returns a GeodesicLine object with point 1 given by latitude, lat1, longitude, lon1, and azimuth azi1 (degrees). Calls to GeodesicLine::Position return the position and azimuth for point 2 a specified distance away. Using GeodesicLine::Position is approximately 2.1 faster than calling Geodesic::Direct.
Definition at line 83 of file Geodesic.cpp.
Math::real GeographicLib::Geodesic::MajorRadius | ( | ) | const throw () [inline] |
The major radius of the ellipsoid (meters). This is that value of a used in the constructor.
Definition at line 193 of file Geodesic.hpp.
Referenced by GeographicLib::CassiniSoldner::MajorRadius(), and GeographicLib::AzimuthalEquidistant::MajorRadius().
Math::real GeographicLib::Geodesic::InverseFlattening | ( | ) | const throw () [inline] |
The inverse flattening of the ellipsoid. This is that value of r used in the constructor. A value of 0 is returned for a sphere (infinite inverse flattening).
Definition at line 200 of file Geodesic.hpp.
Referenced by GeographicLib::CassiniSoldner::InverseFlattening(), and GeographicLib::AzimuthalEquidistant::InverseFlattening().
friend class GeodesicLine [friend] |
Definition at line 74 of file Geodesic.hpp.
const Geodesic GeographicLib::Geodesic::WGS84 [static] |
A global instantiation of Geodesic with the parameters for the WGS84 ellipsoid.
Definition at line 206 of file Geodesic.hpp.