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 }
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
main
int main()
Definition: examples/example-RhumbLine.cpp:13
GeographicLib::Rhumb
Solve of the direct and inverse rhumb problems.
Definition: Rhumb.hpp:66
Rhumb.hpp
Header for GeographicLib::Rhumb and GeographicLib::RhumbLine classes.
GeographicLib::Rhumb::Inverse
void Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi12, real &S12) const
Definition: Rhumb.hpp:338
Constants.hpp
Header for GeographicLib::Constants class.
GeographicLib::RhumbLine
Find a sequence of points on a single rhumb line.
Definition: Rhumb.hpp:437
std
Definition: BFloat16.h:88
GeographicLib::Rhumb::Line
RhumbLine Line(real lat1, real lon1, real azi12) const
Definition: src/Rhumb.cpp:168
ceil
const EIGEN_DEVICE_FUNC CeilReturnType ceil() const
Definition: ArrayCwiseUnaryOps.h:495
GeographicLib::RhumbLine::Position
void Position(real s12, real &lat2, real &lon2, real &S12) const
Definition: Rhumb.hpp:512
lon
static const double lon
Definition: testGeographicLib.cpp:34
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Mon Jul 1 2024 03:01:15