[Positioner] Add Point3D::distance_2d()

This commit is contained in:
Matteo Cypriani 2012-08-24 16:25:26 +02:00
parent b11b63c46b
commit 5fd5f13b93
1 changed files with 12 additions and 0 deletions

View File

@ -57,6 +57,8 @@ public:
float square_distance_2d(const Point3D &p) const ;
/// Square euclidean distance to a Point3D
float square_distance(const Point3D &p) const ;
/// Euclidean distance to a Point3D, in 2D
float distance_2d(const Point3D &p) const ;
/// Euclidean distance to a Point3D
float distance(const Point3D &p) const ;
/// Euclidean distance to the radius of a sphere
@ -166,6 +168,16 @@ inline void Point3D::set_coordinates(const Point3D &source)
/* *** Distance operations *** */
/**
* Note: to compare distances, use preferably square_distance_2d(),
* which is more efficient.
*/
inline float Point3D::distance_2d(const Point3D &source) const
{
return sqrt(square_distance_2d(source)) ;
}
/**
* Note: to compare distances, use preferably square_distance(),
* which is more efficient.