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

后端 未结 13 1552
迷失自我
迷失自我 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:15

    You might want to look at Voronoi Culling. Paper and video here:

    http://www.cs.unc.edu/~geom/DVD/

    0 讨论(0)
  • 2021-02-01 06:23

    Gotta run off to a funeral in a sec, but if you break your polygons down into convex subpolies, there are some optimizations you can do. You can do a binary searches on each poly to find the closest vertex, and then I believe the closest point should either be that vertex, or an adjacent edge. This means you should be able to do it in log(log m * n) where m is the average number of vertices on a poly, and n is the number of polies. This is kind of hastey, so it could be wrong. Will give more details later if wanted.

    0 讨论(0)
  • 2021-02-01 06:24

    For polygon shapes with a reasonable number of boundary points such as in a GIS or games application it might be quicker easier to do a series of tests.

    For each vertex in the red polygon compute the distance to each vertex in the blue polygons and find the closest (hint, compare distance^2 so you don't need the sqrt() ) Find the closest, then check the vertex on each side of the found red and blue vertex to decide which line segments are closest and then find the closest approach between two line segments.

    See http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline3d/ (it's easy to simply for the 2d case)

    0 讨论(0)
  • 2021-02-01 06:24

    I would start by bounding all the polygons by a bounding circle and then finding an upper bound of the minimal distance. Then i would simply check the edges of all blue polygons whose lower bound of distance is lower than the upper bound of minimal distance against all the edges of the red polygon.

    upper bound of min distance = min {distance(red's center, current blue's center) + current blue's radius}
    
    for every blue polygon where distance(red's center, current blue's center) - current blue's radius < upper bound of min distance
        check distance of edges and vertices
    
    

    But it all depends on your data. If the blue polygons are relatively small compared to the distances between them and the red polygon, then this approach should work nicely, but if they are very close, you won't save anything (many of them will be close enough). And another thing -- If these polygons don't have many vertices (like if most of them were triangles), then it might be almost as fast to just check each red edge against each blue edge.

    hope it helps

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-02-01 06:25

    Maybe the Frechet Distance is what your looking for?

    Computing the Fréchet distance between two polygonal curves
    Computing the Fréchet Distance Between Simple Polygons

    0 讨论(0)
提交回复
热议问题