3 * Magnetic variation wrapper class.
6 // Written by Curtis Olson, started July 2000.
8 // Copyright (C) 2000 Curtis L. Olson - curt@flightgear.org
10 // This program is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU General Public License as
12 // published by the Free Software Foundation; either version 2 of the
13 // License, or (at your option) any later version.
15 // This program is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // General Public License for more details.
20 // You should have received a copy of the GNU General Public License
21 // along with this program; if not, write to the Free Software
22 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32 # error This library requires C++
41 * Magnetic variation wrapper class.
43 * The SGMagVar class calculates the magnetic variation and dip for
44 * any position, altitude, and time. It is a complete
45 * re-implimentation of the NIMA WMM 2000 (not derived from their demo
48 * The SGMagVar class is really a simple wrapper around the core Ed
49 * Williams code which does all the hard work. This class allows you
50 * to crunch the math once and then do multiple polls of the
51 * data. However, if your position, altitude, or time has changed
52 * significantly, you should call the update() method to recrunch new
65 * This creates an instance of the SGMagVar object.
66 * You must call the update() method before any queries will be valid.
73 /** Recalculate the magnetic offset and dip.
74 * The update() method requires you to pass in your position and
75 * the julian date. Lon and lat are specified in radians, altitude
76 * is specified in meters. Julian date can be conveniently
77 * calculated by using an instance of the SGTime class.
78 * @param lon longitude in radians
79 * @param lat latitude in radians
80 * @param alt_m altitude above sea level in meters
81 * @param jd julian date
83 void update( double lon, double lat, double alt_m, double jd );
85 /** @return the current magnetic variation in radians. */
86 double get_magvar() const { return magvar; }
88 /** @return the current magnetic dip in radians. */
89 double get_magdip() const { return magdip; }
95 * Lookup the magvar for any arbitrary location (This function doesn't
96 * save state like the SGMagVar class. This function triggers a fair
97 * amount of CPU work, so use it cautiously.
98 * @return the magvar in radians
100 double sgGetMagVar( double lon, double lat, double alt_m, double jd );
103 #endif // _MAGVAR_HXX