I have been searching for solutions to my problem but haven't found any that I could understand fully, feel free to link to solutions.
I want to calculate the x,y co-ordinates of a rectangle which is the intersection of two other 2D, normal rectangles:
| (x4,y4) |
| | | |
| (x2,y2) |
The co-ordinates of the top-left corner are given by:
(max(x4, x0), max(y4, y0)).
The co-ordinates of the bottom-right corner are given by:
(min(x2, x5), min(y2, y5)).
max(x4, x0) > min(x2, x5) or
max(y4,y0) > min(y2, y5) then there is no intersection.