;;;感谢lostbalance与作者,原帖: http://bbs.mjtd.com/thread-178146-1-1.html
(defun intersect (a b)
(if
(or
(and ;;b左下角在a框内
(<= (caar a) (caar b) (caadr a))
(<= (cadar a) (cadar b) (cadadr a))
)
(and ;;b左上角在a框内
(<= (caar a) (caar b) (caadr a))
(<= (cadar a) (cadadr b) (cadadr a))
)
(and ;;b右上角在a框内
(<= (caar a) (caadr b) (caadr a))
(<= (cadar a) (cadadr b) (cadadr a))
)
(and ;;b右下角在a框内
(<= (caar a) (caadr b) (caadr a))
(<= (cadar a) (cadar b) (cadadr a))
)
(and ;;a框部分包含在b框内
(<= (caar a) (caar b) (caadr a)) ;;xa1<=xb1<=xa2
(>= (cadar a) (cadar b)) ;;ya1>=yb1
(<= (cadadr a) (cadadr b)) ;;ya2<=yb2
)
)
(list
(apply 'mapcar (cons 'min (append a b)))
(apply 'mapcar (cons 'max (append a b)))
)
)
)