From 57d418b27cd2f4b75de1672c0a6e58fe2e5546c9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 25 Jul 2008 21:03:44 +0000 Subject: update to 2geom rev. 1507 (bzr r6416) --- src/2geom/path.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/2geom/path.cpp') diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index d39b3ca92..5f321d517 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -194,7 +194,7 @@ Path::allNearestPoints(Point const& _point, double from, double to) const return all_nearest; } -double Path::nearestPoint(Point const& _point, double from, double to) const +double Path::nearestPoint(Point const &_point, double from, double to, double *distance_squared) const { if ( from > to ) std::swap(from, to); const Path& _path = *this; @@ -220,10 +220,11 @@ double Path::nearestPoint(Point const& _point, double from, double to) const } if ( si == ei ) { - double nearest = - _path[si].nearestPoint(_point, st, et); + double nearest = _path[si].nearestPoint(_point, st, et); + *distance_squared = distanceSq(_point, _path[si].pointAt(nearest)); return si + nearest; } + double t; double nearest = _path[si].nearestPoint(_point, st); unsigned int ni = si; @@ -254,8 +255,13 @@ double Path::nearestPoint(Point const& _point, double from, double to) const { nearest = t; ni = ei; + mindistsq = dsq; } } + + if (distance_squared) { + *distance_squared = mindistsq; + } return ni + nearest; } -- cgit v1.2.3