Use valid parameter range [0,1] in calls to Curve.solveCubic().

This commit is contained in:
Jürg Lehni 2014-09-20 11:08:20 +02:00
parent c2465b60fa
commit c94fb3038f

View file

@ -485,6 +485,7 @@ statics: {
return values; return values;
}, },
// TODO: Instead of constants for type, use a "enum" and code substitution.
evaluate: function(v, t, type) { evaluate: function(v, t, type) {
var p1x = v[0], p1y = v[1], var p1x = v[0], p1y = v[1],
c1x = v[2], c1y = v[3], c1x = v[2], c1y = v[3],
@ -595,8 +596,8 @@ statics: {
return 1; return 1;
var txs = [], var txs = [],
tys = [], tys = [],
sx = Curve.solveCubic(v, 0, x, txs), sx = Curve.solveCubic(v, 0, x, txs, 0, 1),
sy = Curve.solveCubic(v, 1, y, tys), sy = Curve.solveCubic(v, 1, y, tys, 0, 1),
tx, ty; tx, ty;
// sx, sy == -1 means infinite solutions: // sx, sy == -1 means infinite solutions:
// Loop through all solutions for x and match with solutions for y, // Loop through all solutions for x and match with solutions for y,