GeographicLib  1.38
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MagneticCircle.cpp
Go to the documentation of this file.
1 /**
2  * \file MagneticCircle.cpp
3  * \brief Implementation for GeographicLib::MagneticCircle class
4  *
5  * Copyright (c) Charles Karney (2011) <charles@karney.com> and licensed under
6  * the MIT/X11 License. For more information, see
7  * http://geographiclib.sourceforge.net/
8  **********************************************************************/
9 
11 #include <fstream>
12 #include <sstream>
14 
15 namespace GeographicLib {
16 
17  using namespace std;
18 
19  void MagneticCircle::Field(real lon, bool diffp,
20  real& Bx, real& By, real& Bz,
21  real& Bxt, real& Byt, real& Bzt) const {
22  real clam, slam;
23  CircularEngine::cossin(lon, clam, slam);
24  real M[Geocentric::dim2_];
25  Geocentric::Rotation(_sphi, _cphi, slam, clam, M);
26  real BX0, BY0, BZ0, BX1, BY1, BZ1; // Components in geocentric basis
27  _circ0(clam, slam, BX0, BY0, BZ0);
28  _circ1(clam, slam, BX1, BY1, BZ1);
29  if (_interpolate) {
30  BX1 = (BX1 - BX0) / _dt0;
31  BY1 = (BY1 - BY0) / _dt0;
32  BZ1 = (BZ1 - BZ0) / _dt0;
33  }
34  BX0 += _t1 * BX1;
35  BY0 += _t1 * BY1;
36  BZ0 += _t1 * BZ1;
37  if (diffp) {
38  Geocentric::Unrotate(M, BX1, BY1, BZ1, Bxt, Byt, Bzt);
39  Bxt *= - _a;
40  Byt *= - _a;
41  Bzt *= - _a;
42  }
43  Geocentric::Unrotate(M, BX0, BY0, BZ0, Bx, By, Bz);
44  Bx *= - _a;
45  By *= - _a;
46  Bz *= - _a;
47  }
48 
49 } // namespace GeographicLib
GeographicLib::Math::real real
Definition: GeodSolve.cpp:40
Header for GeographicLib::MagneticCircle class.
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
Header for GeographicLib::Geocentric class.