2015-12-23 09:25:34 -04:00
|
|
|
#pragma once
|
2012-03-10 15:38:45 -04:00
|
|
|
|
2019-06-01 08:01:11 -03:00
|
|
|
#include <AP_Common/Location.h>
|
|
|
|
|
2012-03-10 15:38:45 -04:00
|
|
|
/*
|
2017-08-17 06:09:00 -03:00
|
|
|
magnetic data derived from WMM
|
2012-08-17 03:19:39 -03:00
|
|
|
*/
|
2012-03-10 15:38:45 -04:00
|
|
|
class AP_Declination
|
|
|
|
{
|
|
|
|
public:
|
2017-08-17 06:09:00 -03:00
|
|
|
/*
|
|
|
|
* Calculates the magnetic intensity, declination and inclination at a given WGS-84 latitude and longitude.
|
|
|
|
* Assumes a WGS-84 height of zero
|
|
|
|
* latitude and longitude have units of degrees
|
|
|
|
* declination and inclination are returned in degrees
|
|
|
|
* intensity is returned in Gauss
|
|
|
|
* Boolean returns false if latitude and longitude are outside the valid input range of +-60 latitude and +-180 longitude
|
|
|
|
*/
|
|
|
|
static bool get_mag_field_ef(float latitude_deg, float longitude_deg, float &intensity_gauss, float &declination_deg, float &inclination_deg);
|
|
|
|
|
2019-06-01 08:01:11 -03:00
|
|
|
/*
|
|
|
|
get earth field as a Vector3f in Gauss given a Location
|
|
|
|
*/
|
|
|
|
static Vector3f get_earth_field_ga(const Location &loc);
|
|
|
|
|
2017-08-17 06:09:00 -03:00
|
|
|
/*
|
|
|
|
get declination in degrees for a given latitude_deg and longitude_deg
|
|
|
|
*/
|
|
|
|
static float get_declination(float latitude_deg, float longitude_deg);
|
|
|
|
|
2012-03-15 00:10:01 -03:00
|
|
|
private:
|
2017-11-01 07:34:38 -03:00
|
|
|
static const float SAMPLING_RES;
|
|
|
|
static const float SAMPLING_MIN_LAT;
|
|
|
|
static const float SAMPLING_MAX_LAT;
|
|
|
|
static const float SAMPLING_MIN_LON;
|
|
|
|
static const float SAMPLING_MAX_LON;
|
|
|
|
|
2022-03-08 09:42:50 -04:00
|
|
|
static const uint32_t LAT_TABLE_SIZE = 19;
|
|
|
|
static const uint32_t LON_TABLE_SIZE = 37;
|
|
|
|
|
|
|
|
static const float declination_table[LAT_TABLE_SIZE][LON_TABLE_SIZE];
|
|
|
|
static const float inclination_table[LAT_TABLE_SIZE][LON_TABLE_SIZE];
|
|
|
|
static const float intensity_table[LAT_TABLE_SIZE][LON_TABLE_SIZE];
|
2012-03-10 15:38:45 -04:00
|
|
|
};
|