CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Declination/AP_Declination.h
Views: 1798
1
#pragma once
2
3
#include <AP_Common/Location.h>
4
5
/*
6
magnetic data derived from WMM
7
*/
8
class AP_Declination
9
{
10
public:
11
/*
12
* Calculates the magnetic intensity, declination and inclination at a given WGS-84 latitude and longitude.
13
* Assumes a WGS-84 height of zero
14
* latitude and longitude have units of degrees
15
* declination and inclination are returned in degrees
16
* intensity is returned in Gauss
17
* Boolean returns false if latitude and longitude are outside the valid input range of +-60 latitude and +-180 longitude
18
*/
19
static bool get_mag_field_ef(float latitude_deg, float longitude_deg, float &intensity_gauss, float &declination_deg, float &inclination_deg);
20
21
/*
22
get earth field as a Vector3f in Gauss given a Location
23
*/
24
static Vector3f get_earth_field_ga(const Location &loc);
25
26
/*
27
get declination in degrees for a given latitude_deg and longitude_deg
28
*/
29
static float get_declination(float latitude_deg, float longitude_deg);
30
31
private:
32
static const float SAMPLING_RES;
33
static const float SAMPLING_MIN_LAT;
34
static const float SAMPLING_MAX_LAT;
35
static const float SAMPLING_MIN_LON;
36
static const float SAMPLING_MAX_LON;
37
38
static const uint32_t LAT_TABLE_SIZE = 19;
39
static const uint32_t LON_TABLE_SIZE = 37;
40
41
static const float declination_table[LAT_TABLE_SIZE][LON_TABLE_SIZE];
42
static const float inclination_table[LAT_TABLE_SIZE][LON_TABLE_SIZE];
43
static const float intensity_table[LAT_TABLE_SIZE][LON_TABLE_SIZE];
44
};
45
46