Adjust #isCollinear() tolerance.

This commit is contained in:
Jürg Lehni 2015-08-26 17:09:40 +02:00
parent 86fd33c7d5
commit d656c96191
2 changed files with 6 additions and 2 deletions

View file

@ -113,7 +113,10 @@ var Line = Base.extend(/** @lends Line# */{
},
isCollinear: function(line) {
return this._vx * line._vy - this._vy * line._vx < 1e-10;
// TODO: Tests showed that 1e-10 might work well here, but we want to
// keep it in sync with Point#isCollinear()
return this._vx * line._vy - this._vy * line._vx
< /*#=*/Numerical.TOLERANCE;
},
statics: /** @lends Line */{

View file

@ -703,7 +703,8 @@ var Point = Base.extend(/** @lends Point# */{
*/
isCollinear: function(point) {
// NOTE: Numerical.EPSILON is too small, breaking shape-path-shape
// conversion test.
// conversion test. But tolerance is probably too large?
// TODO: Tests showed that 1e-10 might work well here.
return Math.abs(this.cross(point)) < /*#=*/Numerical.TOLERANCE;
},