Rename Point#isParallel() to #isColinear(), reimplement it using #cross() and add #isOrthogonal() as well, using #dot().

This commit is contained in:
Jürg Lehni 2011-04-28 15:12:58 +01:00
parent 4b4e092f90
commit 5211e86e3a

View file

@ -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. * another vector.
* *
* @param point the vector to check against * @param point the vector to check against
* @return {@true if it is parallel} * @return {@true if it is parallel}
*/ */
isParallel: function(point) { isColinear: function(point) {
// TODO: Tolerance seems rather high! return this.cross(point) < Numerical.TOLERANCE;
return Math.abs(this.x / point.x - this.y / point.y) < 0.00001; },
/**
* 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;
}, },
/** /**