From 5fd5f13b9387ad01195b49b3309de4ab7197ac49 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Fri, 24 Aug 2012 16:25:26 +0200 Subject: [PATCH] [Positioner] Add Point3D::distance_2d() --- owlps-positioner/src/point3d.hh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/owlps-positioner/src/point3d.hh b/owlps-positioner/src/point3d.hh index 04e2b6c..7a3cb40 100644 --- a/owlps-positioner/src/point3d.hh +++ b/owlps-positioner/src/point3d.hh @@ -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.