examples/example-GeodesicLineExact.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::GeodesicLineExact class
2 
3 #include <iostream>
4 #include <iomanip>
5 #include <exception>
6 #include <cmath>
10 
11 using namespace std;
12 using namespace GeographicLib;
13 
14 int main() {
15  try {
16  // Print waypoints between JFK and SIN
17  GeodesicExact geod(Constants::WGS84_a(), Constants::WGS84_f());
18  // Alternatively: const GeodesicExact& geod = GeodesicExact::WGS84();
19  double
20  lat1 = 40.640, lon1 = -73.779, // JFK
21  lat2 = 1.359, lon2 = 103.989; // SIN
23  geod.InverseLine(lat1, lon1, lat2, lon2);
24  double ds0 = 500e3; // Nominal distance between points = 500 km
25  int num = int(ceil(line.Distance() / ds0)); // The number of intervals
26  cout << fixed << setprecision(3);
27  {
28  // Use intervals of equal length
29  double ds = line.Distance() / num;
30  for (int i = 0; i <= num; ++i) {
31  double lat, lon;
32  line.Position(i * ds, lat, lon);
33  cout << i << " " << lat << " " << lon << "\n";
34  }
35  }
36  {
37  // Slightly faster, use intervals of equal arc length
38  double da = line.Arc() / num;
39  for (int i = 0; i <= num; ++i) {
40  double lat, lon;
41  line.ArcPosition(i * da, lat, lon);
42  cout << i << " " << lat << " " << lon << "\n";
43  }
44  }
45  }
46  catch (const exception& e) {
47  cerr << "Caught exception: " << e.what() << "\n";
48  return 1;
49  }
50 }
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
GeographicLib::GeodesicExact
Exact geodesic calculations.
Definition: GeodesicExact.hpp:80
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeodesicExact.hpp
Header for GeographicLib::GeodesicExact class.
GeodesicLineExact.hpp
Header for GeographicLib::GeodesicLineExact class.
GeographicLib::GeodesicLineExact::ArcPosition
void ArcPosition(real a12, real &lat2, real &lon2, real &azi2, real &s12, real &m12, real &M12, real &M21, real &S12) const
Definition: GeodesicLineExact.hpp:356
GeographicLib::GeodesicLineExact::Distance
Math::real Distance() const
Definition: GeodesicLineExact.hpp:655
GeographicLib::GeodesicExact::InverseLine
GeodesicLineExact InverseLine(real lat1, real lon1, real lat2, real lon2, unsigned caps=ALL) const
Definition: src/GeodesicExact.cpp:538
Constants.hpp
Header for GeographicLib::Constants class.
main
int main()
Definition: examples/example-GeodesicLineExact.cpp:14
GeographicLib::GeodesicLineExact
An exact geodesic line.
Definition: GeodesicLineExact.hpp:35
std
Definition: BFloat16.h:88
GeographicLib::GeodesicLineExact::Position
Math::real Position(real s12, real &lat2, real &lon2, real &azi2, real &m12, real &M12, real &M21, real &S12) const
Definition: GeodesicLineExact.hpp:243
ceil
const EIGEN_DEVICE_FUNC CeilReturnType ceil() const
Definition: ArrayCwiseUnaryOps.h:495
lon
static const double lon
Definition: testGeographicLib.cpp:34
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
GeographicLib::GeodesicLineExact::Arc
Math::real Arc() const
Definition: GeodesicLineExact.hpp:660
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:16