From 00fa07ef331406ebae17ad4abda8b38c5d2c4016 Mon Sep 17 00:00:00 2001 From: Pierre Kancir Date: Mon, 8 Apr 2019 14:22:38 +0200 Subject: [PATCH] AP_Math: move location_diff to Location and rename --- libraries/AP_Common/Location.cpp | 11 +++++++++++ libraries/AP_Common/Location.h | 3 +++ libraries/AP_Math/location.cpp | 10 +--------- libraries/AP_Math/location.h | 6 ------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/libraries/AP_Common/Location.cpp b/libraries/AP_Common/Location.cpp index 022de9ebda..51ff24536d 100644 --- a/libraries/AP_Common/Location.cpp +++ b/libraries/AP_Common/Location.cpp @@ -220,6 +220,17 @@ float Location::get_distance(const struct Location &loc2) const return norm(dlat, dlng) * LOCATION_SCALING_FACTOR; } + +/* + return the distance in meters in North/East plane as a N/E vector + from loc1 to loc2 + */ +Vector2f Location::get_distance_NE(const Location &loc2) const +{ + return Vector2f((loc2.lat - lat) * LOCATION_SCALING_FACTOR, + (loc2.lng - lng) * LOCATION_SCALING_FACTOR * longitude_scale()); +} + // extrapolate latitude/longitude given distances (in meters) north and east void Location::offset(float ofs_north, float ofs_east) { diff --git a/libraries/AP_Common/Location.h b/libraries/AP_Common/Location.h index 02aff84ab5..b299e5108a 100644 --- a/libraries/AP_Common/Location.h +++ b/libraries/AP_Common/Location.h @@ -72,6 +72,9 @@ public: // return distance in meters between two locations float get_distance(const struct Location &loc2) const; + // return the distance in meters in North/East plane as a N/E vector to loc2 + Vector2f get_distance_NE(const Location &loc2) const; + // extrapolate latitude/longitude given distances (in meters) north and east void offset(float ofs_north, float ofs_east); diff --git a/libraries/AP_Math/location.cpp b/libraries/AP_Math/location.cpp index 230fedb21e..ff3d10a7ad 100644 --- a/libraries/AP_Math/location.cpp +++ b/libraries/AP_Math/location.cpp @@ -75,15 +75,7 @@ float location_path_proportion(const struct Location &location, -/* - return the distance in meters in North/East plane as a N/E vector - from loc1 to loc2 - */ -Vector2f location_diff(const struct Location &loc1, const struct Location &loc2) -{ - return Vector2f((loc2.lat - loc1.lat) * LOCATION_SCALING_FACTOR, - (loc2.lng - loc1.lng) * LOCATION_SCALING_FACTOR * loc1.longitude_scale()); -} + /* return the distance in meters in North/East/Down plane as a N/E/D vector diff --git a/libraries/AP_Math/location.h b/libraries/AP_Math/location.h index 5cdb4e73cb..be4b9ce425 100644 --- a/libraries/AP_Math/location.h +++ b/libraries/AP_Math/location.h @@ -42,12 +42,6 @@ float location_path_proportion(const struct Location &location, const struct Location &point1, const struct Location &point2); -/* - return the distance in meters in North/East plane as a N/E vector - from loc1 to loc2 - */ -Vector2f location_diff(const struct Location &loc1, const struct Location &loc2); - /* return the distance in meters in North/East/Down plane as a N/E/D vector from loc1 to loc2