diff options
author | Colin Okay <okay@toyful.space> | 2019-04-16 18:40:01 -0500 |
---|---|---|
committer | Colin Okay <cbeok@protonmail.com> | 2020-10-12 09:37:42 -0500 |
commit | 9959f0ba72e3e87fc257272668329c7235530950 (patch) | |
tree | 542a4a8791367c86722b052317a00ecf2a731c48 | |
parent | 55b3796395c40c86a0774e6864a3bc811ce964ad (diff) |
improved intersection check
-rwxr-xr-x | imbricate.ros | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/imbricate.ros b/imbricate.ros index ab32984..c5eba0c 100755 --- a/imbricate.ros +++ b/imbricate.ros @@ -134,9 +134,15 @@ exec ros -Q -- $0 "$@" (inside-rect r2 (tr r1)) (inside-rect r2 (br r1)) (inside-rect r2 (bl r1)) - )) ;; TODO add the case checks for edge intersections - - + ;; if no corner of one is inside the other, then + ;; any edge of one intersects at least one edge of the other + ;; so we check one arbitrarily + (destructuring-bind (left1 right1 top1 bottom1) (xy-bounds r1) + (destructuring-bind (left2 right2 top2 bottom2) (xy-bounds r2) + (and (<= left1 left2) + (< left2 right1) + (<= top2 top1) + (< top1 bottom2)))))) (defun make-corner-keeper () (list 0 0 '() (make-hash-table :test 'equal) '())) @@ -212,7 +218,6 @@ exec ros -Q -- $0 "$@" (let ((tw (getf stats :width)) (th (getf stats :height))) (destructuring-bind (x y) (find-space-for ck tw th) - (format t "found space: ~a,~a~%" x y) (add-rect ck (rect x y tw th)) (push (nconc (list :x x :y y) stats) packlist)))) packlist)) |