Skip to content

How to Check if Rectangles are Disjoint

Jorj X. McKie edited this page Mar 16, 2017 · 7 revisions

Algebraic functions of rectangle and points can be used to check inclusion of such objects. Questions like "Is rectangle R1 contained in rectangle R2?" or "Is point P outside or inside rectangle R?" can easily be answered.

For rectangles, points and matrices, the list() and tuple() functions will return sequences of the coordinates. Therefore:

tuple(r1 & r2) == (0, 0, 0, 0)

means that r1 and r2 are disjoint.

tuple(r1 | r2) == tuple(r1)

means that r2 is completely contained in r1.

Note that r2 in the above examples can be a rectangle or a point.

Clone this wiki locally