Method to detect intersection between a rectangle and a polygon?

前端 未结 5 883
名媛妹妹
名媛妹妹 2021-01-04 19:46

What is the best method to detect whether the red rectangle overlaps the black polygon? Please refer to this image:

5条回答
  •  无人及你
    2021-01-04 20:28

    If you use axis-aligned rectangles and polygons consist of rectangles only, templatetypedef's answer is what you need.

    If you use arbitrary polygons, it's a much more complex problem. First, you need to subdivide polygons into convex parts, then perform collision detection using, for example, the SAT algorithm

提交回复
热议问题