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