examples/example-RhumbLine.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::RhumbLine class
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <exception>
6 #include <cmath>
9 
10 using namespace std;
11 using namespace GeographicLib;
12 
13 int main() {
14  try {
15  // Print waypoints between JFK and SIN
16  Rhumb rhumb(Constants::WGS84_a(), Constants::WGS84_f());
17  // Alternatively: const Rhumb& rhumb = Rhumb::WGS84();
18  double
19  lat1 = 40.640, lon1 = -73.779, // JFK
20  lat2 = 1.359, lon2 = 103.989; // SIN
21  double s12, azi12;
22  rhumb.Inverse(lat1, lon1, lat2, lon2, s12, azi12);
23  const GeographicLib::RhumbLine line = rhumb.Line(lat1, lon1, azi12);
24  // Alternatively
25  // const GeographicLib::RhumbLine line = rhumb.Line(lat1, lon1, azi1);
26  double ds0 = 500e3; // Nominal distance between points = 500 km
27  int num = int(ceil(s12 / ds0)); // The number of intervals
28  cout << fixed << setprecision(3);
29  {
30  // Use intervals of equal length
31  double ds = s12 / num;
32  for (int i = 0; i <= num; ++i) {
33  double lat, lon;
34  line.Position(i * ds, lat, lon);
35  cout << i << " " << lat << " " << lon << "\n";
36  }
37  }
38  }
39  catch (const exception& e) {
40  cerr << "Caught exception: " << e.what() << "\n";
41  return 1;
42  }
43 }
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12, real &S12) const
Definition: Rhumb.hpp:338
return int(ret)+1
static const double lat
Definition: Half.h:150
Header for GeographicLib::Rhumb and GeographicLib::RhumbLine classes.
EIGEN_DEVICE_FUNC const CeilReturnType ceil() const
RhumbLine Line(real lat1, real lon1, real azi12) const
Definition: src/Rhumb.cpp:168
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Header for GeographicLib::Constants class.
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
Find a sequence of points on a single rhumb line.
Definition: Rhumb.hpp:437
static const double lon
void Position(real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:512


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:02