summaryrefslogtreecommitdiffstats
path: root/src/2geom/path.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-07-25 21:03:44 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-07-25 21:03:44 +0000
commit57d418b27cd2f4b75de1672c0a6e58fe2e5546c9 (patch)
treea5b44b406145087d79d14033b080e6918befc0d3 /src/2geom/path.cpp
parentcopyedit (diff)
downloadinkscape-57d418b27cd2f4b75de1672c0a6e58fe2e5546c9.tar.gz
inkscape-57d418b27cd2f4b75de1672c0a6e58fe2e5546c9.zip
update to 2geom rev. 1507
(bzr r6416)
Diffstat (limited to 'src/2geom/path.cpp')
-rw-r--r--src/2geom/path.cpp12
1 files changed, 9 insertions, 3 deletions
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;
}