examples/example-LocalCartesian.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::LocalCartesian class
2 
3 #include <iostream>
4 #include <exception>
5 #include <cmath>
8 
9 using namespace std;
10 using namespace GeographicLib;
11 
12 int main() {
13  try {
14  Geocentric earth(Constants::WGS84_a(), Constants::WGS84_f());
15  // Alternatively: const Geocentric& earth = Geocentric::WGS84();
16  const double lat0 = 48 + 50/60.0, lon0 = 2 + 20/60.0; // Paris
17  LocalCartesian proj(lat0, lon0, 0, earth);
18  {
19  // Sample forward calculation
20  double lat = 50.9, lon = 1.8, h = 0; // Calais
21  double x, y, z;
22  proj.Forward(lat, lon, h, x, y, z);
23  cout << x << " " << y << " " << z << "\n";
24  }
25  {
26  // Sample reverse calculation
27  double x = -38e3, y = 230e3, z = -4e3;
28  double lat, lon, h;
29  proj.Reverse(x, y, z, lat, lon, h);
30  cout << lat << " " << lon << " " << h << "\n";
31  }
32  }
33  catch (const exception& e) {
34  cerr << "Caught exception: " << e.what() << "\n";
35  return 1;
36  }
37 }
Scalar * y
Header for GeographicLib::LocalCartesian class.
static const double lat
Definition: BFloat16.h:88
Geocentric coordinates
Definition: Geocentric.hpp:67
const double lat0
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const double lon0
Header for GeographicLib::Geocentric class.
Local cartesian coordinates.
void Forward(real lat, real lon, real h, real &x, real &y, real &z) const
const double h
void Reverse(real x, real y, real z, real &lat, real &lon, real &h) const
static const double lon
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x


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