mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 15:33:57 -04:00
AP_Math: add Vector3f::distance_squared
This commit is contained in:
parent
f187df225a
commit
e6328c350d
@ -210,6 +210,14 @@ public:
|
||||
return v * (*this * v)/(v*v);
|
||||
}
|
||||
|
||||
// distance from the tip of this vector to another vector squared (so as to avoid the sqrt calculation)
|
||||
float distance_squared(const Vector3<T> &v) const {
|
||||
float dist_x = x-v.x;
|
||||
float dist_y = y-v.y;
|
||||
float dist_z = z-v.z;
|
||||
return (dist_x*dist_x + dist_y*dist_y + dist_z*dist_z);
|
||||
}
|
||||
|
||||
// given a position p1 and a velocity v1 produce a vector
|
||||
// perpendicular to v1 maximising distance from p1. If p1 is the
|
||||
// zero vector the return from the function will always be the
|
||||
|
Loading…
Reference in New Issue
Block a user