summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/assets/test/intersect.html14
1 files changed, 7 insertions, 7 deletions
diff --git a/public/assets/test/intersect.html b/public/assets/test/intersect.html
index cdce645..0a8526e 100644
--- a/public/assets/test/intersect.html
+++ b/public/assets/test/intersect.html
@@ -71,7 +71,7 @@ function draw () {
intersect.a = vec_a.x.a + ( vec_a.y.a - vec_a.x.a ) * t
intersect.b = vec_a.x.b + ( vec_a.y.b - vec_a.x.b ) * t
- var collinear = is_collinear( intersect.b, vec_b )
+ var collinear = is_collinear( intersect, vec_b )
var long_enough_to_intersect = 0 <= t && t <= 1
if (long_enough_to_intersect && collinear) {
@@ -103,23 +103,23 @@ function drawPoint (p) {
function perp (va, vb) {
return (va.y.a - va.x.a) * (vb.y.b - vb.x.b) - (va.y.b - va.x.b) * (vb.y.a - vb.x.a)
}
-function is_collinear (n, vec) {
+function is_collinear (p, vec) {
var on_x, on_y
if (vec.x.a < vec.y.a) {
- on_x = vec.x.a <= n && n <= vec.y.a
+ on_x = vec.x.a <= p.a && p.a <= vec.y.a
}
else {
- on_x = vec.x.a >= n && n >= vec.y.a
+ on_x = vec.x.a >= p.a && p.a >= vec.y.a
}
if (vec.x.b < vec.y.b) {
- on_y = vec.x.b <= n && n <= vec.y.b
+ on_y = vec.x.b <= p.b && p.b <= vec.y.b
}
else {
- on_y = vec.x.b >= n && n >= vec.y.b
+ on_y = vec.x.b >= p.b && p.b >= vec.y.b
}
-
+
return !! (on_x && on_y)
}