From d656c9619184d237906810ec154d399688097ca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 26 Aug 2015 17:09:40 +0200 Subject: [PATCH] Adjust #isCollinear() tolerance. --- src/basic/Line.js | 5 ++++- src/basic/Point.js | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/basic/Line.js b/src/basic/Line.js index b2295d4c..3d143109 100644 --- a/src/basic/Line.js +++ b/src/basic/Line.js @@ -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 */{ diff --git a/src/basic/Point.js b/src/basic/Point.js index 7ff1ab5a..f9af8718 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -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; },