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

Solve of the direct and inverse rhumb problems. More...

#include <GeographicLib/Rhumb.hpp>

Public Member Functions

 Rhumb (real a, real f, bool exact=true)
 
void Direct (real lat1, real lon1, real azi12, real s12, real &lat2, real &lon2) const
 
void Inverse (real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12) const
 
RhumbLine Line (real lat1, real lon1, real azi12) const
 

Friends

class RhumbLine
 

Inspector functions.

Math::real MajorRadius () const
 
Math::real Flattening () const
 
static const RhumbWGS84 ()
 

Detailed Description

Solve of the direct and inverse rhumb problems.

The path of constant azimuth between two points on a 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 and azi2. (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 .

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.

For more information on rhumb lines see Rhumb lines.

Example of use:

// Example of using the GeographicLib::Rhumb class
#include <iostream>
#include <exception>
using namespace std;
using namespace GeographicLib;
int main() {
try {
// Alternatively: const Rhumb& rhumb = Rhumb::WGS84();
{
// Sample direct calculation, travelling about NE from JFK
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";
}
{
// Sample inverse calculation, JFK to LHR
double
lat1 = 40.6, lon1 = -73.8, // JFK Airport
lat2 = 51.6, lon2 = -0.5; // LHR Airport
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;
}
return 0;
}

Definition at line 48 of file Rhumb.hpp.

Constructor & Destructor Documentation

GeographicLib::Rhumb::Rhumb ( real  a,
real  f,
bool  exact = true 
)
inline

Constructor for a ellipsoid with

Parameters
[in]aequatorial radius (meters).
[in]fflattening of ellipsoid. Setting f = 0 gives a sphere. Negative f gives a prolate ellipsoid. If f > 1, set flattening to 1/f.
[in]exactif true (the default) use an addition theorem for elliptic integrals to compute divided differences; otherwise use series expansion (accurate for |f| < 0.01).
Exceptions
GeographicErrif a or (1 − f) a is not positive.

See Rhumb lines, for a detailed description of the exact parameter.

Definition at line 166 of file Rhumb.hpp.

Member Function Documentation

void GeographicLib::Rhumb::Direct ( real  lat1,
real  lon1,
real  azi12,
real  s12,
real &  lat2,
real &  lon2 
) const

Solve the direct rhumb problem.

Parameters
[in]lat1latitude of point 1 (degrees).
[in]lon1longitude of point 1 (degrees).
[in]azi12azimuth of the rhumb line (degrees).
[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).

lat1 should be in the range [−90°, 90°]; lon1 and azi1 should be in the range [−540°, 540°). The values of lon2 and azi2 returned are in the range [−180°, 180°).

If point 1 is a pole, the cosine of its latitude is taken to be 1/ε2 (where ε is 2-52). This position, which is extremely close to the actual pole, allows the calculation to be carried out in finite terms. 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 40 of file Rhumb.cpp.

Referenced by main().

void GeographicLib::Rhumb::Inverse ( real  lat1,
real  lon1,
real  lat2,
real  lon2,
real &  s12,
real &  azi12 
) const

Solve the inverse rhumb problem.

Parameters
[in]lat1latitude of point 1 (degrees).
[in]lon1longitude of point 1 (degrees).
[in]lat2latitude of point 2 (degrees).
[in]lon2longitude of point 2 (degrees).
[out]s12rhumb distance between point 1 and point 2 (meters).
[out]azi12azimuth of the rhumb line (degrees).

The shortest rhumb line is found. lat1 and lat2 should be in the range [−90°, 90°]; lon1 and lon2 should be in the range [−540°, 540°). The value of azi12 returned is in the range [−180°, 180°).

If either point is a pole, the cosine of its latitude is taken to be 1/ε2 (where ε is 2-52). This position, which is extremely close to the actual pole, allows the calculation to be carried out in finite terms.

Definition at line 23 of file Rhumb.cpp.

References GeographicLib::Math::AngDiff(), GeographicLib::Math::AngNormalize(), GeographicLib::Math::degree(), and GeographicLib::Math::hypot().

Referenced by main().

RhumbLine GeographicLib::Rhumb::Line ( real  lat1,
real  lon1,
real  azi12 
) const

Set up to compute several points on a single rhumb line.

Parameters
[in]lat1latitude of point 1 (degrees).
[in]lon1longitude of point 1 (degrees).
[in]azi12azimuth of the rhumb line (degrees).
Returns
a RhumbLine object.

lat1 should be in the range [−90°, 90°]; lon1 and azi12 should be in the range [−540°, 540°).

If point 1 is a pole, the cosine of its latitude is taken to be 1/ε2 (where ε is 2-52). This position, which is extremely close to the actual pole, allows the calculation to be carried out in finite terms.

Definition at line 37 of file Rhumb.cpp.

Referenced by main().

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

Definition at line 243 of file Rhumb.hpp.

References GeographicLib::Ellipsoid::MajorRadius().

Referenced by GeographicLib::RhumbLine::MajorRadius().

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

Definition at line 249 of file Rhumb.hpp.

References GeographicLib::Ellipsoid::Flattening().

Referenced by GeographicLib::RhumbLine::Flattening().

const Rhumb & GeographicLib::Rhumb::WGS84 ( )
static

A global instantiation of Rhumb with the parameters for the WGS84 ellipsoid.

Definition at line 18 of file Rhumb.cpp.

References GeographicLib::Constants::WGS84_a(), and GeographicLib::Constants::WGS84_f().

Friends And Related Function Documentation

friend class RhumbLine
friend

Definition at line 51 of file Rhumb.hpp.


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