Remove handling of converged fat-line, as it causes issues.

Example 23 in #784 was caused by this, and the code's removal has not produced any new issues, while it solved 6 issues in @iconexperience's test suite.

Closes #795
This commit is contained in:
Jürg Lehni 2015-10-05 17:20:56 +02:00
parent 93cacffd06
commit 1f03b00f99

View file

@ -1450,39 +1450,31 @@ new function() { // Scope for intersection using bezier fat-line clipping
dMax = factor * Math.max(0, d1, d2), dMax = factor * Math.max(0, d1, d2),
tMinNew, tMaxNew, tMinNew, tMaxNew,
tDiff; tDiff;
if (q0x === q3x && uMax - uMin < epsilon && recursion >= 3) { // Calculate non-parametric bezier curve D(ti, di(t)) - di(t) is the
// The fat-line of Q has converged to a point, the clipping is not // distance of P from the baseline l of the fat-line, ti is equally
// reliable. Return the value we have even though we will miss the // spaced in [0, 1]
// precision. var dp0 = getSignedDistance(q0x, q0y, q3x, q3y, v1[0], v1[1]),
tMaxNew = tMinNew = (tMax + tMin) / 2; dp1 = getSignedDistance(q0x, q0y, q3x, q3y, v1[2], v1[3]),
tDiff = 0; dp2 = getSignedDistance(q0x, q0y, q3x, q3y, v1[4], v1[5]),
} else { dp3 = getSignedDistance(q0x, q0y, q3x, q3y, v1[6], v1[7]),
// Calculate non-parametric bezier curve D(ti, di(t)) - di(t) is the // Get the top and bottom parts of the convex-hull
// distance of P from the baseline l of the fat-line, ti is equally hull = getConvexHull(dp0, dp1, dp2, dp3),
// spaced in [0, 1] top = hull[0],
var dp0 = getSignedDistance(q0x, q0y, q3x, q3y, v1[0], v1[1]), bottom = hull[1],
dp1 = getSignedDistance(q0x, q0y, q3x, q3y, v1[2], v1[3]), tMinClip, tMaxClip;
dp2 = getSignedDistance(q0x, q0y, q3x, q3y, v1[4], v1[5]), // Clip the convex-hull with dMin and dMax, taking into account that
dp3 = getSignedDistance(q0x, q0y, q3x, q3y, v1[6], v1[7]), // there will be no intersections if one of the tvalues are null.
// Get the top and bottom parts of the convex-hull if ((tMinClip = clipConvexHull(top, bottom, dMin, dMax)) == null ||
hull = getConvexHull(dp0, dp1, dp2, dp3), (tMaxClip = clipConvexHull(top.reverse(), bottom.reverse(),
top = hull[0], dMin, dMax)) == null)
bottom = hull[1], return;
tMinClip, tMaxClip; // Clip P with the fat-line for Q
// Clip the convex-hull with dMin and dMax, taking into account that v1 = Curve.getPart(v1, tMinClip, tMaxClip);
// there will be no intersections if one of the tvalues are null. tDiff = tMaxClip - tMinClip;
if ((tMinClip = clipConvexHull(top, bottom, dMin, dMax)) == null || // tMin and tMax are within the range (0, 1). We need to project it to
(tMaxClip = clipConvexHull(top.reverse(), bottom.reverse(), // the original parameter range for v2.
dMin, dMax)) == null) tMinNew = tMax * tMinClip + tMin * (1 - tMinClip);
return; tMaxNew = tMax * tMaxClip + tMin * (1 - tMaxClip);
// Clip P with the fat-line for Q
v1 = Curve.getPart(v1, tMinClip, tMaxClip);
tDiff = tMaxClip - tMinClip;
// tMin and tMax are within the range (0, 1). We need to project it
// to the original parameter range for v2.
tMinNew = tMax * tMinClip + tMin * (1 - tMinClip);
tMaxNew = tMax * tMaxClip + tMin * (1 - tMaxClip);
}
// Check if we need to subdivide the curves // Check if we need to subdivide the curves
if (oldTDiff > 0.5 && tDiff > 0.5) { if (oldTDiff > 0.5 && tDiff > 0.5) {
// Subdivide the curve which has converged the least. // Subdivide the curve which has converged the least.