mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Only intersect lines if their lengths are not conflicting with Numerical.EPSILON comparison of the cross product in Line#intersect().
This commit is contained in:
parent
7d0db22b9b
commit
7f81184848
1 changed files with 9 additions and 2 deletions
|
@ -760,8 +760,15 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{
|
|||
return [0.5 * (w[0].x + w[5].x)];
|
||||
// Compute intersection of chord from first control point to last
|
||||
// with x-axis.
|
||||
if (isFlatEnough(w))
|
||||
return [xAxis.intersect(new Line(w[0], w[5], true)).x];
|
||||
if (isFlatEnough(w)) {
|
||||
var line = new Line(w[0], w[5], true);
|
||||
// Compare the line's squared length with EPSILON. If we're
|
||||
// below, #intersect() will return null because of division
|
||||
// by near-zero.
|
||||
return [ line.vector.getLength(true) < Numerical.EPSILON
|
||||
? line.point.x
|
||||
: xAxis.intersect(line).x ];
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise, solve recursively after
|
||||
|
|
Loading…
Reference in a new issue