AP_Declination.h 1.3 KB

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