From 88b29ff18c578051b584ad2921d0fa0d35bc20ef Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Fri, 5 Apr 2019 15:02:43 +0200 Subject: [PATCH] AP_Math: move get_bearing_cd to Location and rename to get_bearing_to --- libraries/AP_Math/examples/location/location.cpp | 2 +- libraries/AP_Math/location.cpp | 10 ---------- libraries/AP_Math/location.h | 3 --- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/libraries/AP_Math/examples/location/location.cpp b/libraries/AP_Math/examples/location/location.cpp index 2bb626ea70..ded00aadd4 100644 --- a/libraries/AP_Math/examples/location/location.cpp +++ b/libraries/AP_Math/examples/location/location.cpp @@ -76,7 +76,7 @@ static void test_one_offset(const struct Location &loc, hal.console->printf("location_offset took %u usec\n", (unsigned)(AP_HAL::micros() - t1)); dist2 = loc.get_distance(loc2); - bearing2 = get_bearing_cd(loc, loc2) * 0.01f; + bearing2 = loc.get_bearing_to(loc2) * 0.01f; float brg_error = bearing2-bearing; if (brg_error > 180) { brg_error -= 360; diff --git a/libraries/AP_Math/location.cpp b/libraries/AP_Math/location.cpp index 4f2cae3da5..cd4303b388 100644 --- a/libraries/AP_Math/location.cpp +++ b/libraries/AP_Math/location.cpp @@ -30,16 +30,6 @@ float get_horizontal_distance_cm(const Vector3f &origin, const Vector3f &destina return norm(destination.x-origin.x,destination.y-origin.y); } -// return bearing in centi-degrees between two locations -int32_t get_bearing_cd(const struct Location &loc1, const struct Location &loc2) -{ - int32_t off_x = loc2.lng - loc1.lng; - const int32_t off_y = (loc2.lat - loc1.lat) / loc2.longitude_scale(); - int32_t bearing = 9000 + atan2f(-off_y, off_x) * DEGX100; - if (bearing < 0) bearing += 36000; - return bearing; -} - // return bearing in centi-degrees between two positions float get_bearing_cd(const Vector3f &origin, const Vector3f &destination) { diff --git a/libraries/AP_Math/location.h b/libraries/AP_Math/location.h index 388841b017..635becdcd3 100644 --- a/libraries/AP_Math/location.h +++ b/libraries/AP_Math/location.h @@ -22,9 +22,6 @@ // return horizontal distance in centimeters between two positions float get_horizontal_distance_cm(const Vector3f &origin, const Vector3f &destination); -// return bearing in centi-degrees between two locations -int32_t get_bearing_cd(const struct Location &loc1, const struct Location &loc2); - // return bearing in centi-degrees between two positions float get_bearing_cd(const Vector3f &origin, const Vector3f &destination);