GeographicLib  1.38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Friends | List of all members
GeographicLib::RhumbLine Class Reference

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
 

Detailed Description

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>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Print waypoints between JFK and SIN
// 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.

Member Function Documentation

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.

Parameters
[in]s12distance between point 1 and point 2 (meters); it can be negative.
[out]lat2latitude of point 2 (degrees).
[out]lon2longitude 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().

Math::real GeographicLib::RhumbLine::Latitude ( ) const
inline
Returns
lat1 the latitude of point 1 (degrees).

Definition at line 310 of file Rhumb.hpp.

Math::real GeographicLib::RhumbLine::Longitude ( ) const
inline
Returns
lon1 the longitude of point 1 (degrees).

Definition at line 315 of file Rhumb.hpp.

Math::real GeographicLib::RhumbLine::Azimuth ( ) const
inline
Returns
azi12 the azimuth of the rhumb line (degrees).

Definition at line 320 of file Rhumb.hpp.

Math::real GeographicLib::RhumbLine::MajorRadius ( ) const
inline
Returns
a the equatorial radius of the ellipsoid (meters). This is the value inherited from the Rhumb object used in the constructor.

Definition at line 326 of file Rhumb.hpp.

Math::real GeographicLib::RhumbLine::Flattening ( ) const
inline
Returns
f the flattening of the ellipsoid. This is the value inherited from the Rhumb object used in the constructor.

Definition at line 332 of file Rhumb.hpp.

Friends And Related Function Documentation

friend class Rhumb
friend

Definition at line 278 of file Rhumb.hpp.


The documentation for this class was generated from the following files: