Fix issue in Curve.getLength() for linear curves with sub-ranges.

Closes #376.
This commit is contained in:
Jürg Lehni 2013-12-30 14:20:05 +01:00
parent 6654dca6bf
commit 6a11547942

View file

@ -1091,12 +1091,13 @@ new function() { // Scope for methods that require numerical integration
b = 1;
var isZero = Numerical.isZero;
// See if the curve is linear by checking p1 == c1 and p2 == c2
if (isZero(v[0] - v[2]) && isZero(v[1] - v[3])
if (a === 0 && b === 1
&& isZero(v[0] - v[2]) && isZero(v[1] - v[3])
&& isZero(v[6] - v[4]) && isZero(v[7] - v[5])) {
// Straight line
var dx = v[6] - v[0], // p2x - p1x
dy = v[7] - v[1]; // p2y - p1y
return (b - a) * Math.sqrt(dx * dx + dy * dy);
return Math.sqrt(dx * dx + dy * dy);
}
var ds = getLengthIntegrand(v);
return Numerical.integrate(ds, a, b, getIterations(a, b));