mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Merge pull request #1081 from sapics/minor-fix
Fix to cover the case when Numerical.solveQuadratic return -1
This commit is contained in:
commit
eb752a43cd
2 changed files with 3 additions and 2 deletions
|
@ -979,7 +979,7 @@ Path.inject(/** @lends Path# */{
|
|||
// Keep then range to 0 .. 1 (excluding) in the search for y
|
||||
// extrema.
|
||||
n = Numerical.solveQuadratic(a, b, c, roots, tMin, tMax);
|
||||
if (n === 0) {
|
||||
if (n < 1) {
|
||||
insertCurve(v);
|
||||
} else {
|
||||
roots.sort();
|
||||
|
|
|
@ -356,7 +356,8 @@ var Numerical = new function() {
|
|||
}
|
||||
// The cubic has been deflated to a quadratic.
|
||||
var count = Numerical.solveQuadratic(a, b1, c2, roots, min, max);
|
||||
if (isFinite(x) && (count === 0 || x !== roots[count - 1])
|
||||
if (isFinite(x) && count >= 0
|
||||
&& (count === 0 || x !== roots[count - 1])
|
||||
&& (min == null || x > min - EPSILON && x < max + EPSILON))
|
||||
roots[count++] = min == null ? x : clamp(x, min, max);
|
||||
return count;
|
||||
|
|
Loading…
Reference in a new issue