diff --git a/vcg/space/segment2.h b/vcg/space/segment2.h index 05e92056..4f1407ce 100644 --- a/vcg/space/segment2.h +++ b/vcg/space/segment2.h @@ -142,7 +142,7 @@ typedef Segment2 Segment2f; typedef Segment2 Segment2d; template -Point2 ClosestPoint( Segment2 s, const Point2 & p) +Point2 ClosestPoint(const Segment2 & s, const Point2 & p) { vcg::Line2 l; l.Set(s.P0(),s.P1()-s.P0()); @@ -157,6 +157,12 @@ Point2 ClosestPoint( Segment2 s, const Point2 +ScalarType Distance(const Segment2 & s, const Point2 & p) { + const Point2 c = ClosestPoint(s, p); + return (c - p).Norm(); +} + template class PointSegment2DEPFunctor { public: