GeographicLib: MagneticCircle.cpp Source File

GeographicLib 2.5.2

Loading...
Searching...
No Matches
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-2021) <karney@alum.mit.edu> and licensed
6 * under the MIT/X11 License. For more information, see
7 * https://geographiclib.sourceforge.io/
8 **********************************************************************/
9
10#include <GeographicLib/MagneticCircle.hpp>
11#include <fstream>
12#include <sstream>
13#include <GeographicLib/Geocentric.hpp>
14
15namespace GeographicLib {
16
17 using namespace std;
18
19 void MagneticCircle::FieldGeocentric(real slam, real clam,
20 real& BX, real& BY, real& BZ,
21 real& BXt, real& BYt, real& BZt) const {
22 real BXc = 0, BYc = 0, BZc = 0;
23 _circ0(slam, clam, BX, BY, BZ);
24 _circ1(slam, clam, BXt, BYt, BZt);
25 if (_constterm)
26 _circ2(slam, clam, BXc, BYc, BZc);
27 if (_interpolate) {
28 BXt = (BXt - BX) / _dt0;
29 BYt = (BYt - BY) / _dt0;
30 BZt = (BZt - BZ) / _dt0;
31 }
32 BX += _t1 * BXt + BXc;
33 BY += _t1 * BYt + BYc;
34 BZ += _t1 * BZt + BZc;
35
36 BXt *= - _a;
37 BYt *= - _a;
38 BZt *= - _a;
39
40 BX *= - _a;
41 BY *= - _a;
42 BZ *= - _a;
43 }
44
45 void MagneticCircle::FieldGeocentric(real lon,
46 real& BX, real& BY, real& BZ,
47 real& BXt, real& BYt, real& BZt) const {
48 real slam, clam;
49 Math::sincosd(lon, slam, clam);
50 FieldGeocentric(slam, clam, BX, BY, BZ, BXt, BYt, BZt);
51 }
52
53 void MagneticCircle::Field(real lon, bool diffp,
54 real& Bx, real& By, real& Bz,
55 real& Bxt, real& Byt, real& Bzt) const {
56 real slam, clam;
57 Math::sincosd(lon, slam, clam);
58 real M[Geocentric::dim2_];
59 Geocentric::Rotation(_sphi, _cphi, slam, clam, M);
60 real BX, BY, BZ, BXt, BYt, BZt; // Components in geocentric basis
61 FieldGeocentric(slam, clam, BX, BY, BZ, BXt, BYt, BZt);
62 if (diffp)
63 Geocentric::Unrotate(M, BXt, BYt, BZt, Bxt, Byt, Bzt);
64 Geocentric::Unrotate(M, BX, BY, BZ, Bx, By, Bz);
65 }
66
67} // namespace GeographicLib
Geocentric.hpp
Header for GeographicLib::Geocentric class.
real
GeographicLib::Math::real real
Definition GeodSolve.cpp:28
MagneticCircle.hpp
Header for GeographicLib::MagneticCircle class.
GeographicLib::Math::sincosd
static void sincosd(T x, T &sinx, T &cosx)
Definition Math.cpp:104
GeographicLib
Namespace for GeographicLib.
Definition Accumulator.cpp:12