Find a sequence of points on a single rhumb line. More...
#include <GeographicLib/Rhumb.hpp>
Public Member Functions | |
void | Position (real s12, real &lat2, real &lon2) const |
Inspector functions | |
Math::real | Latitude () const |
Math::real | Longitude () const |
Math::real | Azimuth () const |
Math::real | MajorRadius () const |
Math::real | Flattening () const |
Friends | |
class | Rhumb |
Find a sequence of points on a single rhumb line.
RhumbLine facilitates the determination of a series of points on a single rhumb line. The starting point (lat1, lon1) and the azimuth azi12 are specified in the call to Rhumb::Line which returns a RhumbLine object. RhumbLine.Position returns the location of point 2 a distance s12 along the rhumb line.
There is no public constructor for this class. (Use Rhumb::Line to create an instance.) The Rhumb object used to create a RhumbLine must stay in scope as long as the RhumbLine.
Example of use:
// Example of using the GeographicLib::RhumbLine class #include <iostream> #include <exception> #include <cmath> #include <iomanip> #include <GeographicLib/Rhumb.hpp> #include <GeographicLib/Constants.hpp> using namespace std; using namespace GeographicLib; int main() { try { // Print waypoints between JFK and SIN Rhumb rhumb(Constants::WGS84_a(), Constants::WGS84_f()); // Alternatively: const Rhumb& rhumb = Rhumb::WGS84(); double lat1 = 40.640, lon1 = -73.779, // JFK lat2 = 1.359, lon2 = 103.989; // SIN double s12, azi12; rhumb.Inverse(lat1, lon1, lat2, lon2, s12, azi12); const GeographicLib::RhumbLine line = rhumb.Line(lat1, lon1, azi12); // Alternatively // const GeographicLib::RhumbLine line = rhumb.Line(lat1, lon1, azi1); double ds = 500e3; // Nominal distance between points = 500 km int num = int(ceil(s12 / ds)); // The number of intervals cout << fixed << setprecision(3); { // Use intervals of equal length double ds = s12 / num; for (int i = 0; i <= num; ++i) { double lat, lon; line.Position(i * ds, lat, lon); cout << i << " " << lat << " " << lon << "\n"; } } } catch (const exception& e) { cerr << "Caught exception: " << e.what() << "\n"; return 1; } return 0; }
Definition at line 275 of file Rhumb.hpp.
void GeographicLib::RhumbLine::Position | ( | real | s12, | |
real & | lat2, | |||
real & | lon2 | |||
) | const |
Compute the position of point 2 which is a distance s12 (meters) from point 1.
[in] | s12 | distance between point 1 and point 2 (meters); it can be negative. |
[out] | lat2 | latitude of point 2 (degrees). |
[out] | lon2 | longitude of point 2 (degrees). |
The values of lon2 and azi2 returned are in the range [180, 180).
If s12 is large enough that the rhumb line crosses a pole, the longitude of point 2 is indeterminate (a NaN is returned for lon2).
Definition at line 193 of file Rhumb.cpp.
References GeographicLib::Math::AngNormalize(), GeographicLib::Math::AngNormalize2(), GeographicLib::Math::degree(), GeographicLib::Ellipsoid::InverseRectifyingLatitude(), GeographicLib::Math::NaN(), and GeographicLib::Ellipsoid::QuarterMeridian().
Referenced by GeographicLib::Rhumb::Direct().
Math::real GeographicLib::RhumbLine::Latitude | ( | ) | const [inline] |
Math::real GeographicLib::RhumbLine::Longitude | ( | ) | const [inline] |
Math::real GeographicLib::RhumbLine::Azimuth | ( | ) | const [inline] |
Math::real GeographicLib::RhumbLine::MajorRadius | ( | ) | const [inline] |
Math::real GeographicLib::RhumbLine::Flattening | ( | ) | const [inline] |