Merge pull request #1081 from sapics/minor-fix

Fix to cover the case when Numerical.solveQuadratic return -1
This commit is contained in:
Jürg Lehni 2016-06-16 09:53:54 +02:00 committed by GitHub
commit eb752a43cd
2 changed files with 3 additions and 2 deletions

View file

@ -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();

View file

@ -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;