mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -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;
|
||||
if (p1x == c1x && p1y == c1y && p2x == c2x && p2y == c2y) {
|
||||
// Straight line, calculate directly
|
||||
// t = length / lineLength:
|
||||
var dx = p2x - p1x,
|
||||
dy = p2y - p1y;
|
||||
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(
|
||||
p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
|
||||
// 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
|
||||
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
|
||||
// bring us closer:
|
||||
return Numerical.brent(f, 0, length / bezierLength,
|
||||
|
|
Loading…
Reference in a new issue