From 5211e86e3a3cdd7abcf1a2148fe785e5f60ea4d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 28 Apr 2011 15:12:58 +0100 Subject: [PATCH] Rename Point#isParallel() to #isColinear(), reimplement it using #cross() and add #isOrthogonal() as well, using #dot(). --- src/basic/Point.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/basic/Point.js b/src/basic/Point.js index b554c195..d79042ab 100644 --- a/src/basic/Point.js +++ b/src/basic/Point.js @@ -353,15 +353,25 @@ var Point = this.Point = Base.extend({ }, /** - * Checks if the vector represented by this point is parallel (collinear) to + * Checks if the vector represented by this point is colinear (parallel) to * another vector. * * @param point the vector to check against * @return {@true if it is parallel} */ - isParallel: function(point) { - // TODO: Tolerance seems rather high! - return Math.abs(this.x / point.x - this.y / point.y) < 0.00001; + isColinear: function(point) { + return this.cross(point) < Numerical.TOLERANCE; + }, + + /** + * Checks if the vector represented by this point is orthogonal + * (perpendicular) to another vector. + * + * @param point the vector to check against + * @return {@true if it is orthogonal} + */ + isOrthogonal: function(point) { + return this.dot(point) < Numerical.TOLERANCE; }, /**