diff --git a/src/basic/Line.js b/src/basic/Line.js index 42ec32dd..13e45dd4 100644 --- a/src/basic/Line.js +++ b/src/basic/Line.js @@ -113,9 +113,8 @@ var Line = Base.extend(/** @lends Line# */{ point.x, point.y, true)); }, - isCollinear: function(line, sameDir) { - return Point.isCollinear(this._vx, this._vy, line._vx, line._vy, - sameDir); + isCollinear: function(line) { + return Point.isCollinear(this._vx, this._vy, line._vx, line._vy); }, isOrthogonal: function(line) { diff --git a/src/basic/Point.js b/src/basic/Point.js index f8202465..55f0265b 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -704,9 +704,8 @@ var Point = Base.extend(/** @lends Point# */{ * @return {Boolean} {@true it is collinear} */ isCollinear: function(/* point */) { - var point = Point.read(arguments), - sameDir = Base.read(arguments); - return Point.isCollinear(this.x, this.y, point.x, point.y, sameDir); + var point = Point.read(arguments); + return Point.isCollinear(this.x, this.y, point.x, point.y); }, // TODO: Remove version with typo after a while (deprecated June 2015) @@ -918,16 +917,14 @@ var Point = Base.extend(/** @lends Point# */{ return new Point(Math.random(), Math.random()); }, - isCollinear: function(x1, y1, x2, y2, sameDir) { + isCollinear: function(x1, y1, x2, y2) { // NOTE: We use normalized vectors so that the epsilon comparison is // reliable. We could instead scale the epsilon based on the vector // length. But instead of normalizing the vectors before calculating // the cross product, we can scale the epsilon accordingly. - var d2 = x2 * x2 + y2 * y2; return Math.abs(x1 * y2 - y1 * x2) - <= Math.sqrt((x1 * x1 + y1 * y1) * d2) - * /*#=*/Numerical.TRIGONOMETRIC_EPSILON - && (!sameDir || (x1 * x2 + y1 * y2) / d2 >= 0); + <= Math.sqrt((x1 * x1 + y1 * y1) * (x2 * x2 + y2 * y2)) + * /*#=*/Numerical.TRIGONOMETRIC_EPSILON; }, isOrthogonal: function(x1, y1, x2, y2) { diff --git a/src/path/Curve.js b/src/path/Curve.js index 694fb874..083eb3c0 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -949,9 +949,9 @@ statics: { * @param {Curve} curve the other curve to check against * @return {Boolean} {@true if the two lines are collinear} */ - isCollinear: function(curve, sameDir) { + isCollinear: function(curve) { return curve && this.isStraight() && curve.isStraight() - && this.getLine().isCollinear(curve.getLine(), sameDir); + && this.getLine().isCollinear(curve.getLine()); }, /**