diff --git a/owlps-positioner/src/point3d.cc b/owlps-positioner/src/point3d.cc index 256eb0e..db9110e 100644 --- a/owlps-positioner/src/point3d.cc +++ b/owlps-positioner/src/point3d.cc @@ -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. diff --git a/owlps-positioner/src/point3d.hh b/owlps-positioner/src/point3d.hh index a46d761..4972447 100644 --- a/owlps-positioner/src/point3d.hh +++ b/owlps-positioner/src/point3d.hh @@ -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