Switch to new Curve.getParameterOf()

Simpler code, but improved precision means more glitches to analyze.
This commit is contained in:
Jürg Lehni 2015-10-09 10:34:46 +02:00
parent 48bb0a1be4
commit 688f580b95

View file

@ -615,7 +615,7 @@ statics: {
return Numerical.solveCubic(a, b, c, p1 - val, roots, min, max);
},
getParameterOf: function(v, point) {
getParameterOf_: function(v, point) {
// Handle beginnings and end separately, as they are not detected
// sometimes.
var x = point.x,
@ -666,6 +666,21 @@ statics: {
return null;
},
getParameterOf: function(v, point) {
var coords = [point.x, point.y],
roots = [];
for (var c = 0; c < 2; c++) {
var count = Curve.solveCubic(v, c, coords[c], roots, 0, 1);
for (var i = 0; i < count; i++) {
var t = roots[i],
pt = Curve.getPoint(v, t);
if (point.isClose(pt, /*#=*/Numerical.GEOMETRIC_EPSILON))
return t;
}
}
return null;
},
// TODO: Find better name
getPart: function(v, from, to) {
var flip = from > to;