I have n rectangles and I need to find how many of them overlap. Which I have done and created an intersection matrix which looks like this for the below JSON where each entry presents a rectangle and 1 represents there is an overlap. It is a symmetric matrix and i have assumed that a rectangle overlaps itself.
{
"rects": [
{"x": 100, "y": 100, "w": 250, "h": 80 },
{"x": 120, "y": 200, "w": 250, "h": 150 },
{"x": 140, "y": 160, "w": 250, "h": 100 },
{"x": 160, "y": 140, "w": 350, "h": 190 }
]
}
Now I know that there can be 2 or more rectangles overlapping each other. How can I find them using this intersection matrix? Or is there any other approach for this?
e.g 1,3,4 and 2,3,4