find overlapping rectangles algorithm

后端 未结 12 1789
悲&欢浪女
悲&欢浪女 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 17:55

    Let your set of rectangle be (Xi1,Yi1,Xi2,Yi2) where i varies from 0 to N.

    Rectangle A and B can NOT be intersecting if Ax1 > Bx2 || Ay1 < By2 || Bx1 > Ax2 || By1 < Ay2.

    Create tree which is optimized for range/interval (For exa: segment tree or interval tree) See http://w3.jouy.inra.fr/unites/miaj/public/vigneron/cs4235/l5cs4235.pdf

    Use this tree to find set of triangle while your triangle is changing coordinates.

提交回复
热议问题