Browse Source

AP_Math: Use DEGX100 define instead of hardcoded value (NFC)

mission-4.1.18
Dr.-Ing. Amilcar Do Carmo Lucas 7 years ago committed by Randy Mackay
parent
commit
ec1790dad9
  1. 5
      libraries/AP_Math/definitions.h
  2. 2
      libraries/AP_Math/location.cpp

5
libraries/AP_Math/definitions.h

@ -30,6 +30,9 @@ @@ -30,6 +30,9 @@
#define DEG_TO_RAD (M_PI / 180.0f)
#define RAD_TO_DEG (180.0f / M_PI)
// Centi-degrees to radians
#define DEGX100 5729.57795f
// GPS Specific double precision conversions
// The precision here does matter when using the wsg* functions for converting
// between LLH and ECEF coordinates.
@ -44,7 +47,7 @@ static const double RAD_TO_DEG_DOUBLE = 1 / DEG_TO_RAD_DOUBLE; @@ -44,7 +47,7 @@ static const double RAD_TO_DEG_DOUBLE = 1 / DEG_TO_RAD_DOUBLE;
// radius of earth in meters
#define RADIUS_OF_EARTH 6378100
// convert a longitude or latitude point to meters or centimeteres.
// convert a longitude or latitude point to meters or centimeters.
// Note: this does not include the longitude scaling which is dependent upon location
#define LATLON_TO_M 0.01113195f
#define LATLON_TO_CM 1.113195f

2
libraries/AP_Math/location.cpp

@ -51,7 +51,7 @@ int32_t get_bearing_cd(const struct Location &loc1, const struct Location &loc2) @@ -51,7 +51,7 @@ int32_t get_bearing_cd(const struct Location &loc1, const struct Location &loc2)
{
int32_t off_x = loc2.lng - loc1.lng;
int32_t off_y = (loc2.lat - loc1.lat) / longitude_scale(loc2);
int32_t bearing = 9000 + atan2f(-off_y, off_x) * 5729.57795f;
int32_t bearing = 9000 + atan2f(-off_y, off_x) * DEGX100;
if (bearing < 0) bearing += 36000;
return bearing;
}

Loading…
Cancel
Save