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

This commit is contained in:
Dr.-Ing. Amilcar Do Carmo Lucas 2017-12-03 20:44:47 +01:00 committed by Randy Mackay
parent 4eaa1f17df
commit ec1790dad9
2 changed files with 5 additions and 2 deletions

View File

@ -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;
// 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

View File

@ -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;
}