mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Export Numerical object and move KAPPA constant there.
This commit is contained in:
parent
9cc0822477
commit
90f2614d52
4 changed files with 8 additions and 10 deletions
|
@ -23,7 +23,7 @@
|
|||
function checkValues() {
|
||||
var min = values.radius * 2;
|
||||
if (values.tolerance < min) values.tolerance = min;
|
||||
handle = values.radius * 0.5522847498; // kappa
|
||||
handle = values.radius * Numerical.KAPPA;
|
||||
}
|
||||
|
||||
var path;
|
||||
|
|
|
@ -56,8 +56,7 @@ Path.inject({ statics: new function() {
|
|||
return path;
|
||||
}
|
||||
|
||||
// Kappa, see: http://www.whizkidtech.redprince.net/bezier/circle/kappa/
|
||||
var kappa = 2 * (Math.sqrt(2) - 1) / 3;
|
||||
var kappa = Numerical.KAPPA;
|
||||
|
||||
var ellipseSegments = [
|
||||
new Segment([0, 0.5], [0, kappa ], [0, -kappa]),
|
||||
|
|
|
@ -112,13 +112,10 @@ new function() {
|
|||
seg4._point.subtract(seg3._point));
|
||||
}
|
||||
|
||||
// Kappa, see: http://www.whizkidtech.redprince.net/bezier/circle/kappa/
|
||||
var kappa = 4 * (Math.sqrt(2) - 1) / 3;
|
||||
|
||||
// Returns true if the segment at the given index is the beginning of
|
||||
// a orthogonal arc segment. The code is looking at the length of the
|
||||
// handles and their relation to the distance to the imaginary corner
|
||||
// point. If the relation is kappa (see above), then it's an arc.
|
||||
// point. If the relation is kappa, then it's an arc.
|
||||
function isArc(i) {
|
||||
var segment = segments[i],
|
||||
next = segment.getNext(),
|
||||
|
@ -132,9 +129,9 @@ new function() {
|
|||
corner = new Line(from, handle1).intersect(
|
||||
new Line(to, handle2));
|
||||
return corner && Numerical.isZero(handle1.getLength() /
|
||||
corner.subtract(from).getLength() - kappa)
|
||||
corner.subtract(from).getLength() - Numerical.KAPPA)
|
||||
&& Numerical.isZero(handle2.getLength() /
|
||||
corner.subtract(to).getLength() - kappa);
|
||||
corner.subtract(to).getLength() - Numerical.KAPPA);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* All rights reserved.
|
||||
*/
|
||||
|
||||
var Numerical = new function() {
|
||||
var Numerical = this.Numerical = new function() {
|
||||
|
||||
// Lookup tables for abscissas and weights with values for n = 2 .. 16.
|
||||
// As values are symetric, only store half of them and addapt algorithm
|
||||
|
@ -68,6 +68,8 @@ var Numerical = new function() {
|
|||
// Precision when comparing against 0
|
||||
// TODO: Find a good value
|
||||
EPSILON: 10e-12,
|
||||
// Kappa, see: http://www.whizkidtech.redprince.net/bezier/circle/kappa/
|
||||
KAPPA: 2 * (sqrt(2) - 1) / 3,
|
||||
|
||||
/**
|
||||
* Check if the value is 0, within a tolerance defined by
|
||||
|
|
Loading…
Reference in a new issue