SimGear - Simulator Construction Tools
SGMagVar Class Reference

#include <magvar.hxx>

Public Member Functions

 SGMagVar ()
 
 ~SGMagVar ()
 
double get_magdip () const
 
double get_magvar () const
 
void update (double lon, double lat, double alt_m, double jd)
 
void update (const SGGeod &geod, double jd)
 

Private Attributes

double magdip
 
double magvar
 

Related Functions

(Note that these are not member functions.)

double sgGetMagVar (double lon, double lat, double alt_m, double jd)
 

Detailed Description

Magnetic variation wrapper class.

The SGMagVar class calculates the magnetic variation and dip for any position, altitude, and time. It is a complete re-implimentation of the NIMA WMM 2000 (not derived from their demo code.)

The SGMagVar class is really a simple wrapper around the core Ed Williams code which does all the hard work. This class allows you to crunch the math once and then do multiple polls of the data. However, if your position, altitude, or time has changed significantly, you should call the update() method to recrunch new numbers.

Definition at line 54 of file magvar.hxx.

Constructor & Destructor Documentation

SGMagVar::SGMagVar ( )

This creates an instance of the SGMagVar object. You must call the update() method before any queries will be valid.

Definition at line 38 of file magvar.cxx.

SGMagVar::~SGMagVar ( )

Destructor

Definition at line 44 of file magvar.cxx.

Member Function Documentation

double SGMagVar::get_magdip ( ) const
inline
Returns
the current magnetic dip in radians.

Definition at line 93 of file magvar.hxx.

double SGMagVar::get_magvar ( ) const
inline
Returns
the current magnetic variation in radians.

Definition at line 90 of file magvar.hxx.

void SGMagVar::update ( double  lon,
double  lat,
double  alt_m,
double  jd 
)

Recalculate the magnetic offset and dip. The update() method requires you to pass in your position and the julian date. Lon and lat are specified in radians, altitude is specified in meters. Julian date can be conveniently calculated by using an instance of the SGTime class.

Parameters
lonlongitude in radians
latlatitude in radians
alt_maltitude above sea level in meters
jdjulian date

Definition at line 48 of file magvar.cxx.

Referenced by update().

void SGMagVar::update ( const SGGeod geod,
double  jd 
)

overloaded variant taking an SGGeod to specify position

Definition at line 56 of file magvar.cxx.

Friends And Related Function Documentation

double sgGetMagVar ( double  lon,
double  lat,
double  alt_m,
double  jd 
)
related

Lookup the magvar for any arbitrary location (This function doesn't save state like the SGMagVar class. This function triggers a fair amount of CPU work, so use it cautiously.

Returns
the magvar in radians

Definition at line 63 of file magvar.cxx.

Referenced by sgGetMagVar().

Member Data Documentation

double SGMagVar::magdip
private

Definition at line 59 of file magvar.hxx.

Referenced by get_magdip(), and update().

double SGMagVar::magvar
private

Definition at line 58 of file magvar.hxx.

Referenced by get_magvar(), and update().


The documentation for this class was generated from the following files: