Method to detect intersection between a rectangle and a polygon?

前端 未结 5 875
名媛妹妹
名媛妹妹 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:38

    If you know for a fact that the red rectangle is always axis-aligned and that the black region consists of several axis-aligned rectangles (I'm not sure if this is just a coincidence or if it's inherent to the problem), then you can use the rectangle-on-rectangle intersection algorithm to very efficiently compute whether the two shapes overlap and, if so, where they overlap.

提交回复
热议问题