examples/example-Geocentric.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::Geocentric class
2 
3 #include <iostream>
4 #include <exception>
5 #include <cmath>
7 
8 using namespace std;
9 using namespace GeographicLib;
10 
11 int main() {
12  try {
13  Geocentric earth(Constants::WGS84_a(), Constants::WGS84_f());
14  // Alternatively: const Geocentric& earth = Geocentric::WGS84();
15  {
16  // Sample forward calculation
17  double lat = 27.99, lon = 86.93, h = 8820; // Mt Everest
18  double X, Y, Z;
19  earth.Forward(lat, lon, h, X, Y, Z);
20  cout << floor(X / 1000 + 0.5) << " "
21  << floor(Y / 1000 + 0.5) << " "
22  << floor(Z / 1000 + 0.5) << "\n";
23  }
24  {
25  // Sample reverse calculation
26  double X = 302e3, Y = 5636e3, Z = 2980e3;
27  double lat, lon, h;
28  earth.Reverse(X, Y, Z, lat, lon, h);
29  cout << lat << " " << lon << " " << h << "\n";
30  }
31  }
32  catch (const exception& e) {
33  cerr << "Caught exception: " << e.what() << "\n";
34  return 1;
35  }
36 }
static const double lat
Definition: Half.h:150
void Forward(real lat, real lon, real h, real &X, real &Y, real &Z) const
Definition: Geocentric.hpp:132
Geocentric coordinates
Definition: Geocentric.hpp:67
#define Z
Definition: icosphere.cpp:21
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Header for GeographicLib::Geocentric class.
const double h
void Reverse(real X, real Y, real Z, real &lat, real &lon, real &h) const
Definition: Geocentric.hpp:194
EIGEN_DEVICE_FUNC const FloorReturnType floor() const
static const double lon
#define X
Definition: icosphere.cpp:20


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