summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2007-04-08 21:33:31 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2007-04-08 21:33:31 +0000
commit856e32c8ecaa5df14a879aa8cbe8b150886012a8 (patch)
tree40e6e3e45a424fde140fba8751df782fb8a5c3eb /src
parentChanges to the selector tool, e.g. option to choose either APPROXIMATE_BBOX o... (diff)
downloadinkscape-856e32c8ecaa5df14a879aa8cbe8b150886012a8.tar.gz
inkscape-856e32c8ecaa5df14a879aa8cbe8b150886012a8.zip
fix bug where nearest_point_on_path returned bogus t values on sharp bends
(bzr r2834)
Diffstat (limited to 'src')
-rw-r--r--src/livarot/PathCutting.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp
index 59de29676..276c9b260 100644
--- a/src/livarot/PathCutting.cpp
+++ b/src/livarot/PathCutting.cpp
@@ -991,9 +991,15 @@ Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos) const
double nearestY = (localPos[NR::X] * gradient + localPos[NR::Y] - intersection * gradient)
/ (gradient * gradient + 1.0);
t = (nearestY - p1[NR::Y]) / (p2[NR::Y] - p1[NR::Y]);
- if (t <= 0.0) thisRangeSquared = square(p1[NR::X] - localPos[NR::X]) + square(p1[NR::Y] - localPos[NR::Y]);
- else if (t >= 1.0) thisRangeSquared = square(p2[NR::X] - localPos[NR::X]) + square(p2[NR::Y] - localPos[NR::Y]);
- else thisRangeSquared = square(nearestY * gradient + intersection - localPos[NR::X]) + square(nearestY - localPos[NR::Y]);
+ if (t <= 0.0) {
+ thisRangeSquared = square(p1[NR::X] - localPos[NR::X]) + square(p1[NR::Y] - localPos[NR::Y]);
+ t = 0.0;
+ } else if (t >= 1.0) {
+ thisRangeSquared = square(p2[NR::X] - localPos[NR::X]) + square(p2[NR::Y] - localPos[NR::Y]);
+ t = 1.0;
+ } else {
+ thisRangeSquared = square(nearestY * gradient + intersection - localPos[NR::X]) + square(nearestY - localPos[NR::Y]);
+ }
}
if (thisRangeSquared < bestRangeSquared) {
@@ -1008,10 +1014,11 @@ Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos) const
result.t = 0.0;
} else {
result.piece = pts[bestSeg].piece;
- if (result.piece == pts[bestSeg - 1].piece)
+ if (result.piece == pts[bestSeg - 1].piece) {
result.t = pts[bestSeg - 1].t * (1.0 - bestT) + pts[bestSeg].t * bestT;
- else
+ } else {
result.t = pts[bestSeg].t * bestT;
+ }
}
return result;
}