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 }
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
GeographicLib::Geocentric::Reverse
void Reverse(real X, real Y, real Z, real &lat, real &lon, real &h) const
Definition: Geocentric.hpp:194
X
#define X
Definition: icosphere.cpp:20
h
const double h
Definition: testSimpleHelicopter.cpp:19
main
int main()
Definition: examples/example-Geocentric.cpp:11
GeographicLib::Geocentric
Geocentric coordinates
Definition: Geocentric.hpp:67
GeographicLib::Geocentric::Forward
void Forward(real lat, real lon, real h, real &X, real &Y, real &Z) const
Definition: Geocentric.hpp:132
Geocentric.hpp
Header for GeographicLib::Geocentric class.
std
Definition: BFloat16.h:88
lon
static const double lon
Definition: testGeographicLib.cpp:34
Z
#define Z
Definition: icosphere.cpp:21
floor
const EIGEN_DEVICE_FUNC FloorReturnType floor() const
Definition: ArrayCwiseUnaryOps.h:481
lat
static const double lat
Definition: testGeographicLib.cpp:34


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