What is the quickest way to find the shortest cartesian distance between two polygons

后端 未结 13 1584
迷失自我
迷失自我 2021-02-01 05:54

I have 1 red polygon say and 50 randomly placed blue polygons - they are situated in geographical 2D space. What is the quick

13条回答
  •  长发绾君心
    2021-02-01 06:24

    You could start by comparing the distance between the bounding boxes. Testing the distance between rectangles is easier than testing the distance between polygons, and you can immediately eliminate any polygons that are more than nearest_rect + its_diagonal away (possibly you can refine that even more). Then, you can test the remaining polygons to find the closest polygon.

    There are algorithms for finding polygon proximity - I'm sure Wikipedia has a good review of them. If I recall correctly, those that only allow convex polygons are substantially faster.

提交回复
热议问题