examples/example-MagneticCircle.cpp
Go to the documentation of this file.
1 // Example of using the GeographicLib::MagneticCircle class
2 
3 #include <iostream>
4 #include <exception>
7 
8 using namespace std;
9 using namespace GeographicLib;
10 
11 int main() {
12  try {
13  MagneticModel mag("wmm2010");
14  double lat = 27.99, lon0 = 86.93, h = 8820, t = 2012; // Mt Everest
15  {
16  // Slow method of evaluating the values at several points on a circle of
17  // latitude.
18  for (int i = -5; i <= 5; ++i) {
19  double lon = lon0 + i * 0.2;
20  double Bx, By, Bz;
21  mag(t, lat, lon, h, Bx, By, Bz);
22  cout << lon << " " << Bx << " " << By << " " << Bz << "\n";
23  }
24  }
25  {
26  // Fast method of evaluating the values at several points on a circle of
27  // latitude using MagneticCircle.
28  MagneticCircle circ = mag.Circle(t, lat, h);
29  for (int i = -5; i <= 5; ++i) {
30  double lon = lon0 + i * 0.2;
31  double Bx, By, Bz;
32  circ(lon, Bx, By, Bz);
33  cout << lon << " " << Bx << " " << By << " " << Bz << "\n";
34  }
35  }
36  }
37  catch (const exception& e) {
38  cerr << "Caught exception: " << e.what() << "\n";
39  return 1;
40  }
41 }
static const double lat
Header for GeographicLib::MagneticCircle class.
Definition: BFloat16.h:88
Model of the earth&#39;s magnetic field.
Geomagnetic field on a circle of latitude.
Namespace for GeographicLib.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const double lon0
Header for GeographicLib::MagneticModel class.
const double h
static const double lon
Point2 t(10, 10)
MagneticCircle Circle(real t, real lat, real h) const


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