[Positioner] Point3D: add square_distance_2d()

This commit is contained in:
Matteo Cypriani 2012-04-27 15:28:55 +02:00
parent 007594683c
commit 8d4fa6883d
2 changed files with 14 additions and 0 deletions

View File

@ -41,6 +41,18 @@ Point3D::Point3D(const string &source)
/* *** Distance operations *** */
/**
* The distance is not square rooted after the computation, in order
* to optimise comparisons.
*/
float Point3D::square_distance_2d(const Point3D &source) const
{
return
(x - source.x) * (x - source.x) +
(y - source.y) * (y - source.y) ;
}
/**
* The distance is not square rooted after the computation, in order
* to optimise comparisons.

View File

@ -53,6 +53,8 @@ public:
/** @name Distance & angles operations */
//@{
/// Square euclidean distance to a Point3D, in 2D
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