examples/example-Geodesic.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::Geodesic class
2 
3 #include <iostream>
4 #include <exception>
7 
8 using namespace std;
9 using namespace GeographicLib;
10 
11 int main() {
12  try {
13  Geodesic geod(Constants::WGS84_a(), Constants::WGS84_f());
14  // Alternatively: const Geodesic& geod = Geodesic::WGS84();
15  {
16  // Sample direct calculation, travelling about NE from JFK
17  double lat1 = 40.6, lon1 = -73.8, s12 = 5.5e6, azi1 = 51;
18  double lat2, lon2;
19  geod.Direct(lat1, lon1, azi1, s12, lat2, lon2);
20  cout << lat2 << " " << lon2 << "\n";
21  }
22  {
23  // Sample inverse calculation, JFK to LHR
24  double
25  lat1 = 40.6, lon1 = -73.8, // JFK Airport
26  lat2 = 51.6, lon2 = -0.5; // LHR Airport
27  double s12;
28  geod.Inverse(lat1, lon1, lat2, lon2, s12);
29  cout << s12 << "\n";
30  }
31  }
32  catch (const exception& e) {
33  cerr << "Caught exception: " << e.what() << "\n";
34  return 1;
35  }
36 }
Definition: BFloat16.h:88
Header for GeographicLib::Geodesic class.
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Math::real Direct(real lat1, real lon1, real azi1, real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const
Definition: Geodesic.hpp:379
Header for GeographicLib::Constants class.
Geodesic calculations
Definition: Geodesic.hpp:172
Math::real Inverse(real lat1, real lon1, real lat2, real lon2, real &s12, real &azi1, real &azi2, real &m12, real &M12, real &M21, real &S12) const
Definition: Geodesic.hpp:674


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:12