How to compute the union polygon of two (or more) rectangles

后端 未结 4 1706
无人及你
无人及你 2021-02-06 10:10

For example we have two rectangles and they overlap. I want to get the exact range of the union of them. What is a good way to compute this?

These are the two overlappi

4条回答
  •  南旧
    南旧 (楼主)
    2021-02-06 10:44

    Look into binary space partitioning (BSP).

    https://en.wikipedia.org/wiki/Binary_space_partitioning

    If you had just two rectangles then a bit of hacking could yield some result, but for finding intersections and unions of multiple polygons you'll want to implement BSP.

    Chapter 13 of Geometric Tools for Computer Graphics by Schneider and Eberly covers BSP. Be sure to download the errata for the book!

    Eberly, one of the co-authors, has a wonderful website with PDFs and code samples for individual topics:

    https://www.geometrictools.com/

    http://www.geometrictools.com/Books/Books.html

提交回复
热议问题