diff options
author | David Thompson <dthompson2@worcester.edu> | 2013-10-16 19:55:41 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2013-10-16 19:55:41 -0400 |
commit | 08c94c4d3c267a10e9ab6ee38fd179f0a5103ee4 (patch) | |
tree | f22495aeaa35c95aefc2252b179c6b6c77ded7b1 | |
parent | 3307f1b381eb12999d39984486146ed504dbb6c2 (diff) |
Simplify rect-intersects? procedure.
-rw-r--r-- | 2d/rect.scm | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/2d/rect.scm b/2d/rect.scm index b4bc3af..2420fa9 100644 --- a/2d/rect.scm +++ b/2d/rect.scm @@ -156,14 +156,10 @@ not overlap, a rect of size 0 is returned." (define (rect-intersects? rect1 rect2) "Return #t if RECT2 overlaps RECT1." - (or (and (>= (rect-x rect2) (rect-x rect1)) - (<= (rect-x rect2) (rect-x2 rect1))) - (and (>= (rect-x2 rect2) (rect-x rect1)) - (<= (rect-x2 rect2) (rect-x2 rect1)))) - (or (and (>= (rect-y rect2) (rect-y rect1)) - (<= (rect-y rect2) (rect-y2 rect1))) - (and (>= (rect-y2 rect2) (rect-y rect1)) - (<= (rect-y2 rect2) (rect-y2 rect1))))) + (and (<= (rect-x rect1) (rect-x2 rect2)) + (>= (rect-x2 rect1) (rect-x rect2)) + (<= (rect-y rect1) (rect-y2 rect2)) + (>= (rect-y2 rect1) (rect-y rect2)))) (define (%rect-contains? rect x y) (and (>= x (rect-x rect)) |