1 | initial version |
Hi.
The percentage of overlapping is: area_of_intersection / area_of_union * 100.
To calculate the area of intersection (from this link):
left = max(r1.left, r2.left) right = min(r1.right, r2.right) bottom = max(r1.bottom, r2.bottom) top = min(r1.top, r2.top)
Verify that the intersection is not empty:
left < right && bottom < top
A picture to show the problem:
2 | No.2 Revision |
Hi.
The percentage of overlapping is: area_of_intersection / area_of_union * 100.
To calculate get the intersection rectangle and thus the area of intersection (from this link):) with an origin point at the top left:
left = max(r1.left, r2.left) right = min(r1.right, r2.right) bottom =
max(r1.bottom,min(r1.bottom, r2.bottom) top =min(r1.top,max(r1.top, r2.top)
Verify that the intersection is not empty:
left < right && bottom
<> top
A picture to show the problem: