epibook / epibook.github.io

Publishes to Github Pages
335 stars 238 forks source link

Question: IntersectRectangle.java #34

Closed viditmaniyar closed 7 years ago

viditmaniyar commented 7 years ago

Can someone please help me get my head around the isIntersect method in the IntersectRectangle.java file?

Why do we check for

R1.x <= R2.x + R2.width && R1.x + R1.width >= R2.x && R1.y <= R2.y + R2.height && R1.y + R1.height >= R2.y;

A variety of examples will help.

viditmaniyar commented 7 years ago

Found a SO answer that explains the logic.