find overlapping rectangles algorithm

后端 未结 12 1754
悲&欢浪女
悲&欢浪女 2020-12-16 17:29

let\'s say I have a huge set of non-overlapping rectangle with integer coordinates, who are fixed once and for all

I have another rectangle A with integer coordinate

12条回答
  •  囚心锁ツ
    2020-12-16 18:09

    You can create two vectors of rectangle indexes (because two diagonal points uniquely define your rectangle), and sort them by one of coordinates. Then you search for overlaps using those two index arrays, which is going to be logarithmic instead of linear complexity.

提交回复
热议问题