From b17d165d0c13ea1d7fccf84ee20fba07e27f6738 Mon Sep 17 00:00:00 2001 From: dibenedetto Date: Tue, 6 Oct 2009 16:22:35 +0000 Subject: [PATCH] Added SquaredDistance and made the point-plane version redirect to the plane-point one. --- vcg/space/plane3.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/vcg/space/plane3.h b/vcg/space/plane3.h index 35f25bc0..046b4a85 100644 --- a/vcg/space/plane3.h +++ b/vcg/space/plane3.h @@ -174,14 +174,26 @@ public: typedef Plane3 Plane3f; typedef Plane3 Plane3d; -///Distance plane - point (Move this function to somewhere else) -template T Distance(const Plane3 &plane, const Point3 &point) { +///Distance plane - point and vv. (Move these function to somewhere else) +template T Distance(const Plane3 & plane, const Point3 & point) +{ return plane.Direction().dot(point) - plane.Offset(); } - ///Distance point-plane (Move this function to somewhere else) -template T Distance(const Point3 &point, const Plane3 &plane) { - return plane.Direction().dot(point) - plane.Offset(); +template T SquaredDistance(const Plane3 & plane, const Point3 & point) +{ + const T d = Distance(plane, point); + return (d * d); +} + +template T Distance(const Point3 & point, const Plane3 & plane) +{ + return Distance(plane, point); +} + +template T SquaredDistance(const Point3 & point, const Plane3 & plane) +{ + return SquaredDistance(plane, point); } } // end namespace