GeographicLib  1.37
MagneticCircle.hpp
Go to the documentation of this file.
1 /**
2  * \file MagneticCircle.hpp
3  * \brief Header 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 
10 #if !defined(GEOGRAPHICLIB_MAGNETICCIRCLE_HPP)
11 #define GEOGRAPHICLIB_MAGNETICCIRCLE_HPP 1
12 
13 #include <vector>
16 
17 namespace GeographicLib {
18 
19  /**
20  * \brief Geomagnetic field on a circle of latitude
21  *
22  * Evaluate the earth's magnetic field on a circle of constant height and
23  * latitude. This uses a CircularEngine to pre-evaluate the inner sum of the
24  * spherical harmonic sum, allowing the values of the field at several
25  * different longitudes to be evaluated rapidly.
26  *
27  * Use MagneticModel::Circle to create a MagneticCircle object. (The
28  * constructor for this class is private.)
29  *
30  * Example of use:
31  * \include example-MagneticCircle.cpp
32  *
33  * <a href="MagneticField.1.html">MagneticField</a> is a command-line utility
34  * providing access to the functionality of MagneticModel and MagneticCircle.
35  **********************************************************************/
36 
38  private:
39  typedef Math::real real;
40 
41  real _a, _f, _lat, _h, _t, _cphi, _sphi, _t1, _dt0;
42  bool _interpolate;
43  CircularEngine _circ0, _circ1;
44 
45  MagneticCircle(real a, real f, real lat, real h, real t,
46  real cphi, real sphi, real t1, real dt0,
47  bool interpolate,
48  const CircularEngine& circ0, const CircularEngine& circ1)
49  : _a(a)
50  , _f(f)
51  , _lat(lat)
52  , _h(h)
53  , _t(t)
54  , _cphi(cphi)
55  , _sphi(sphi)
56  , _t1(t1)
57  , _dt0(dt0)
58  , _interpolate(interpolate)
59  , _circ0(circ0)
60  , _circ1(circ1)
61  {}
62 
63  void Field(real lon, bool diffp,
64  real& Bx, real& By, real& Bz,
65  real& Bxt, real& Byt, real& Bzt) const;
66 
67  friend class MagneticModel; // MagneticModel calls the private constructor
68 
69  public:
70 
71  /**
72  * A default constructor for the normal gravity. This sets up an
73  * uninitialized object which can be later replaced by the
74  * MagneticModel::Circle.
75  **********************************************************************/
76  MagneticCircle() : _a(-1) {}
77 
78  /** \name Compute the magnetic field
79  **********************************************************************/
80  ///@{
81  /**
82  * Evaluate the components of the geomagnetic field at a particular
83  * longitude.
84  *
85  * @param[in] lon longitude of the point (degrees).
86  * @param[out] Bx the easterly component of the magnetic field (nanotesla).
87  * @param[out] By the northerly component of the magnetic field (nanotesla).
88  * @param[out] Bz the vertical (up) component of the magnetic field
89  * (nanotesla).
90  **********************************************************************/
91  void operator()(real lon, real& Bx, real& By, real& Bz) const {
92  real dummy;
93  Field(lon, false, Bx, By, Bz, dummy, dummy, dummy);
94  }
95 
96  /**
97  * Evaluate the components of the geomagnetic field and their time
98  * derivatives at a particular longitude.
99  *
100  * @param[in] lon longitude of the point (degrees).
101  * @param[out] Bx the easterly component of the magnetic field (nanotesla).
102  * @param[out] By the northerly component of the magnetic field (nanotesla).
103  * @param[out] Bz the vertical (up) component of the magnetic field
104  * (nanotesla).
105  * @param[out] Bxt the rate of change of \e Bx (nT/yr).
106  * @param[out] Byt the rate of change of \e By (nT/yr).
107  * @param[out] Bzt the rate of change of \e Bz (nT/yr).
108  **********************************************************************/
109  void operator()(real lon, real& Bx, real& By, real& Bz,
110  real& Bxt, real& Byt, real& Bzt) const {
111  Field(lon, true, Bx, By, Bz, Bxt, Byt, Bzt);
112  }
113  ///@}
114 
115  /** \name Inspector functions
116  **********************************************************************/
117  ///@{
118  /**
119  * @return true if the object has been initialized.
120  **********************************************************************/
121  bool Init() const { return _a > 0; }
122  /**
123  * @return \e a the equatorial radius of the ellipsoid (meters). This is
124  * the value inherited from the MagneticModel object used in the
125  * constructor.
126  **********************************************************************/
128  { return Init() ? _a : Math::NaN(); }
129  /**
130  * @return \e f the flattening of the ellipsoid. This is the value
131  * inherited from the MagneticModel object used in the constructor.
132  **********************************************************************/
134  { return Init() ? _f : Math::NaN(); }
135  /**
136  * @return the latitude of the circle (degrees).
137  **********************************************************************/
139  { return Init() ? _lat : Math::NaN(); }
140  /**
141  * @return the height of the circle (meters).
142  **********************************************************************/
144  { return Init() ? _h : Math::NaN(); }
145  /**
146  * @return the time (fractional years).
147  **********************************************************************/
148  Math::real Time() const
149  { return Init() ? _t : Math::NaN(); }
150 
151  ///@}
152  };
153 
154 } // namespace GeographicLib
155 
156 #endif // GEOGRAPHICLIB_MAGNETICCIRCLE_HPP
static T NaN()
Definition: Math.hpp:460
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:70
GeographicLib::Math::real real
Definition: GeodSolve.cpp:40
void operator()(real lon, real &Bx, real &By, real &Bz) const
Model of the earth's magnetic field.
Geomagnetic field on a circle of latitude.
Math::real MajorRadius() const
Namespace for GeographicLib.
Definition: Accumulator.cpp:12
Header for GeographicLib::CircularEngine class.
Spherical harmonic sums for a circle.
void operator()(real lon, real &Bx, real &By, real &Bz, real &Bxt, real &Byt, real &Bzt) const
Header for GeographicLib::Constants class.
Math::real Flattening() const