mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Clean-up code and comments.
This commit is contained in:
parent
add0bcf1fd
commit
172212c222
1 changed files with 3 additions and 2 deletions
|
@ -330,12 +330,11 @@ var Curve = this.Curve = Base.extend({
|
||||||
return 0;
|
return 0;
|
||||||
if (p1x == c1x && p1y == c1y && p2x == c2x && p2y == c2y) {
|
if (p1x == c1x && p1y == c1y && p2x == c2x && p2y == c2y) {
|
||||||
// Straight line, calculate directly
|
// Straight line, calculate directly
|
||||||
|
// t = length / lineLength:
|
||||||
var dx = p2x - p1x,
|
var dx = p2x - p1x,
|
||||||
dy = p2y - p1y;
|
dy = p2y - p1y;
|
||||||
return Math.min(length / Math.sqrt(dx * dx + dy * dy), 1);
|
return Math.min(length / Math.sqrt(dx * dx + dy * dy), 1);
|
||||||
}
|
}
|
||||||
// Let's use the Van Wijngaarden–Dekker–Brent Method to find
|
|
||||||
// solutions more reliably than with False Position Method.
|
|
||||||
var ds = getLengthIntegrand(
|
var ds = getLengthIntegrand(
|
||||||
p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
|
p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
|
||||||
// Use integrand both to calculate total length and part lengths
|
// Use integrand both to calculate total length and part lengths
|
||||||
|
@ -347,6 +346,8 @@ var Curve = this.Curve = Base.extend({
|
||||||
// The precision of 5 iterations seems enough for this
|
// The precision of 5 iterations seems enough for this
|
||||||
return length - Numerical.gauss(ds, 0, t, 5);
|
return length - Numerical.gauss(ds, 0, t, 5);
|
||||||
}
|
}
|
||||||
|
// Let's use the Van Wijngaarden–Dekker–Brent Method to find
|
||||||
|
// solutions more reliably than with False Position Method.
|
||||||
// Use length / bezierLength for an initial guess for b, to
|
// Use length / bezierLength for an initial guess for b, to
|
||||||
// bring us closer:
|
// bring us closer:
|
||||||
return Numerical.brent(f, 0, length / bezierLength,
|
return Numerical.brent(f, 0, length / bezierLength,
|
||||||
|
|
Loading…
Reference in a new issue