summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 484ca63)
raw | patch | inline | side by side (parent: 484ca63)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 8 Apr 2007 21:33:31 +0000 (21:33 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sun, 8 Apr 2007 21:33:31 +0000 (21:33 +0000) |
src/livarot/PathCutting.cpp | patch | blob | history |
index 59de29676f21a6280e99d5410b440739b6ec4a5b..276c9b260f4796b6a0ec8e9642e6a3153fdb36e9 100644 (file)
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;
}