Steve Whitfield
Steve Whitfield

Reputation: 2029

How can I find a natural border polygon of a set of arbitrarily placed non-overlapping rectangles?

Given a set of arbitrarily placed, non-overlapping rectangles; how could I find a polygon that represents a natural border around the points that make up the rectangles? To illustrate:enter image description here

How can I find either the green or blue line? I have tried, but not succeeded, with the following:

I'm unsure if I'm missing something obvious or if this is actually a harder problem than I initially expected.

Upvotes: 1

Views: 78

Answers (1)

Joseph O'Rourke
Joseph O'Rourke

Reputation: 4406

Here is a heuristic. Compute the hull H1 of the rectangles. Now compute the hull H2 of the rectangle corners not on H1. So now you have two nested convex hulls. Consider moving an edge e of H1 to a vertex v of H2. Some such moves can be excluded because the two new edges cross a rectangle. Choose to accept the smallest altitudes of the triangle formed by e and v, as suggested in the image below.


    HullOnion


Upvotes: 1

Related Questions