A Python system to compare the oposite coordinates in 2 rectangles and determine if they intersect.
- Input top left and bottom right coordinates of 2 rectagles
- Calculate all corner coodinates of the 2 rectangles
- Algorithimcly determine if the 2 rectangles intercent
- Buult in Unit Testing
Click to view overlapping example
Info for rectangle 1
Enter X coordinate 1 (top left)0
Enter Y coordinate 1 (top left)10
Enter X coordinate 2 (bottom right)10
Enter Y coordinate 2 (bottom right)0
Info for rectangle 2
Enter X coordinate 1 (top left)1
Enter Y coordinate 1 (top left)11
Enter X coordinate 2 (bottom right)9
Enter Y coordinate 2 (bottom right)-1
True
Click to view non overlapping example
Info for rectangle 1
Enter X coordinate 1 (top left)0
Enter Y coordinate 1 (top left)10
Enter X coordinate 2 (bottom right)10
Enter Y coordinate 2 (bottom right)0
Info for rectangle 2
Enter X coordinate 1 (top left)-5
Enter Y coordinate 1 (top left)10
Enter X coordinate 2 (bottom right)-1
Enter Y coordinate 2 (bottom right)0
False
Click to view testing results
.................
----------------------------------------------------------------------
Ran 17 tests in 0.000s
OK
- Python (tested) 3.13.7+
- Unittest (tested) 3.14+