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 }
MagneticModel.hpp
Header for GeographicLib::MagneticModel class.
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::MagneticModel
Model of the earth's magnetic field.
Definition: MagneticModel.hpp:69
h
const double h
Definition: testSimpleHelicopter.cpp:19
example::lon0
const double lon0
Definition: testGPSFactor.cpp:41
MagneticCircle.hpp
Header for GeographicLib::MagneticCircle class.
std
Definition: BFloat16.h:88
GeographicLib::MagneticModel::Circle
MagneticCircle Circle(real t, real lat, real h) const
Definition: src/MagneticModel.cpp:212
lon
static const double lon
Definition: testGeographicLib.cpp:34
align_3::t
Point2 t(10, 10)
main
int main()
Definition: examples/example-MagneticCircle.cpp:11
GeographicLib::MagneticCircle
Geomagnetic field on a circle of latitude.
Definition: MagneticCircle.hpp:37
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
lat
static const double lat
Definition: testGeographicLib.cpp:34


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