mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -05:00
Rename Point#isParallel() to #isColinear(), reimplement it using #cross() and add #isOrthogonal() as well, using #dot().
This commit is contained in:
parent
4b4e092f90
commit
5211e86e3a
1 changed files with 14 additions and 4 deletions
|
@ -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;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue