Check if polygon is inside a polygon

后端 未结 5 1133
鱼传尺愫
鱼传尺愫 2020-12-01 06:35

Yesterday I was looking to check if a point was inside a polygon and found this great script: https://github.com/tparkin/Google-Maps-Point-in-Polygon

But today at wo

5条回答
  •  孤街浪徒
    2020-12-01 07:27

    Perform line intersection tests for each pair of lines, one from each polygon. If no pairs of lines intersect and one of the line end-points of polygon A is inside polygon B, then A is entirely inside B.

    The above works for any type of polygon. If the polygons are convex, you can skip the line intersection tests and just test that all line end-points of A are inside B.

    If really necessary, you can speed up the line intersection tests using the sweep line algorithm.

提交回复
热议问题