mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Introduce new TRIGONOMETRIC_EPSILON with higher precision than GEOMETRIC_EPSILON.
This commit is contained in:
parent
f5012a78e9
commit
9b883e5fb6
3 changed files with 10 additions and 4 deletions
|
@ -708,7 +708,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
// TODO: Optimize by creating a static Point.isCollinear() to be used
|
||||
// in Line.isCollinear() as well.
|
||||
return Math.abs(this.normalize().cross(point.normalize()))
|
||||
< /*#=*/Numerical.GEOMETRIC_EPSILON;
|
||||
< /*#=*/Numerical.TRIGONOMETRIC_EPSILON;
|
||||
},
|
||||
|
||||
// TODO: Remove version with typo after a while (deprecated June 2015)
|
||||
|
@ -727,7 +727,7 @@ var Point = Base.extend(/** @lends Point# */{
|
|||
// length.
|
||||
// TODO: Optimize
|
||||
return Math.abs(this.normalize().dot(point.normalize()))
|
||||
< /*#=*/Numerical.GEOMETRIC_EPSILON;
|
||||
< /*#=*/Numerical.TRIGONOMETRIC_EPSILON;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -916,7 +916,7 @@ statics: {
|
|||
*/
|
||||
isHorizontal: function() {
|
||||
return this.isStraight() && Math.abs(this.getTangentAt(0.5, true).y)
|
||||
< /*#=*/Numerical.GEOMETRIC_EPSILON;
|
||||
< /*#=*/Numerical.TRIGONOMETRIC_EPSILON;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -926,7 +926,7 @@ statics: {
|
|||
*/
|
||||
isVertical: function() {
|
||||
return this.isStraight() && Math.abs(this.getTangentAt(0.5, true).x)
|
||||
< /*#=*/Numerical.GEOMETRIC_EPSILON;
|
||||
< /*#=*/Numerical.TRIGONOMETRIC_EPSILON;
|
||||
}
|
||||
}), /** @lends Curve# */{
|
||||
// Explicitly deactivate the creation of beans, as we have functions here
|
||||
|
|
|
@ -94,6 +94,12 @@ var Numerical = new function() {
|
|||
* trial and error.
|
||||
*/
|
||||
GEOMETRIC_EPSILON: 1e-7,
|
||||
/**
|
||||
* The epsilon to be used when performing "trigonometric" checks, such
|
||||
* as examining cross products to check for collinearity. This value is
|
||||
* somewhat arbitrary and was chosen by trial and error.
|
||||
*/
|
||||
TRIGONOMETRIC_EPSILON: 1e-8,
|
||||
/**
|
||||
* MACHINE_EPSILON for a double precision (Javascript Number) is
|
||||
* 2.220446049250313e-16. (try this in the js console)
|
||||
|
|
Loading…
Reference in a new issue