GeographicLib: GeographicLib::Rhumb Class Reference (original) (raw)
Solve of the direct and inverse rhumb problems.
The path of constant azimuth between two points on an ellipsoid at (lat1, lon1) and (lat2, lon2) is called the rhumb line (also called the loxodrome). Its length is s12 and its azimuth is azi12. (The azimuth is the heading measured clockwise from north.)
Given lat1, lon1, azi12, and s12, we can determine lat2, and lon2. This is the direct rhumb problem and its solution is given by the function Rhumb::Direct.
Given lat1, lon1, lat2, and lon2, we can determine azi12 and s12. This is the inverse rhumb problem, whose solution is given by Rhumb::Inverse. This finds the shortest such rhumb line, i.e., the one that wraps no more than half way around the earth. If the end points are on opposite meridians, there are two shortest rhumb lines and the east-going one is chosen.
These routines also optionally calculate the area under the rhumb line, S12. This is the area, measured counter-clockwise, of the rhumb line quadrilateral with corners (lat1,lon1), (0,lon1), (0,lon2), and (lat2,lon2).
Note that rhumb lines may be appreciably longer (up to 50%) than the corresponding Geodesic. For example the distance between London Heathrow and Tokyo Narita via the rhumb line is 11400 km which is 18% longer than the geodesic distance 9600 km.
This implementation is described in
- C. F. F. Karney,
The area of rhumb polygons,
Stud. Geophys. Geod. 68(3–4), 99–120 (2024); DOI: 10.1007/s11200-024-0709-z.
For more information on rhumb lines see Rhumb lines.
Example of use:
#include
#include
using namespace std;
try {
Rhumb rhumb(Constants::WGS84_a(), Constants::WGS84_f());
{
double lat1 = 40.6, lon1 = -73.8, s12 = 5.5e6, azi12 = 51;
double lat2, lon2;
rhumb.Direct(lat1, lon1, azi12, s12, lat2, lon2);
cout << lat2 << " " << lon2 << "\n";
}
{
double
lat1 = 40.6, lon1 = -73.8,
lat2 = 51.6, lon2 = -0.5;
double s12, azi12;
rhumb.Inverse(lat1, lon1, lat2, lon2, s12, azi12);
cout << s12 << " " << azi12 << "\n";
}
}
catch (const exception& e) {
cerr << "Caught exception: " << e.what() << "\n";
return 1;
}
}
int main(int argc, const char *const argv[])
Header for GeographicLib::Constants class.
Header for GeographicLib::Rhumb and GeographicLib::RhumbLine classes.
Solve of the direct and inverse rhumb problems.
Namespace for GeographicLib.