Intersection of N rectangles

前端 未结 6 537
野趣味
野趣味 2020-12-25 15:18

I\'m looking for an algorithm to solve this problem:

Given N rectangles on the Cartesian coordinate, find out if the intersection of those rectangles is empty or no

6条回答
  •  误落风尘
    2020-12-25 15:55

    Pick the smallest rectangle from the set (or any rectangle), and go over each point within it. If one of it's point also exists in all other rectangles, the intersection is not empty. If all points are free from ALL other rectangles, the intersection is empty.

提交回复
热议问题