diff --git a/libraries/AP_Common/Location.cpp b/libraries/AP_Common/Location.cpp index 506467af10..158eef76cb 100644 --- a/libraries/AP_Common/Location.cpp +++ b/libraries/AP_Common/Location.cpp @@ -231,6 +231,14 @@ Vector2f Location::get_distance_NE(const Location &loc2) const (loc2.lng - lng) * LOCATION_SCALING_FACTOR * longitude_scale()); } +// return the distance in meters in North/East/Down plane as a N/E/D vector to loc2 +Vector3f Location::get_distance_NED(const Location &loc2) const +{ + return Vector3f((loc2.lat - lat) * LOCATION_SCALING_FACTOR, + (loc2.lng - lng) * LOCATION_SCALING_FACTOR * longitude_scale(), + (alt - loc2.alt) * 0.01f); +} + // 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 471eab591a..9987e124a6 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/Down plane as a N/E/D vector to loc2 + Vector3f get_distance_NED(const 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; diff --git a/libraries/AP_Math/location.cpp b/libraries/AP_Math/location.cpp index 760be2b8b1..69b68c1fe3 100644 --- a/libraries/AP_Math/location.cpp +++ b/libraries/AP_Math/location.cpp @@ -77,16 +77,6 @@ float location_path_proportion(const struct Location &location, -/* - return the distance in meters in North/East/Down plane as a N/E/D vector - from loc1 to loc2 - */ -Vector3f location_3d_diff_NED(const struct Location &loc1, const struct Location &loc2) -{ - return Vector3f((loc2.lat - loc1.lat) * LOCATION_SCALING_FACTOR, - (loc2.lng - loc1.lng) * LOCATION_SCALING_FACTOR * loc1.longitude_scale(), - (loc1.alt - loc2.alt) * 0.01f); -} // return true when lat and lng are within range diff --git a/libraries/AP_Math/location.h b/libraries/AP_Math/location.h index 292b3e3952..354980e834 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/Down plane as a N/E/D vector - from loc1 to loc2 - */ -Vector3f location_3d_diff_NED(const struct Location &loc1, const struct Location &loc2); - // Converts from WGS84 geodetic coordinates (lat, lon, height) // into WGS84 Earth Centered, Earth Fixed (ECEF) coordinates