Exploding Connected Shapes

40 Views Asked by At

I have recently been tasked with creating an 'exploded' view for what amounts to a collection of shapes in a 2d coordinate plane. These shapes are all touching in some way. What I need to do is translate all of the coordinates of these shapes in such a way that I create gaps in between them with aesthetically pleasing gaps.

As stated before, I have a list of all of the line segments / arcs that make up these shapes. I've spent some time looking around on google, but honestly I think I lack the vocabulary for that to be effective. I'm not exactly a mathematician, and this might not be the right stack exchange for this so I expect this to be difficult. I'm merely seeking guidance here, not necessarily a solution. Any help here would be appreciated.

Say I start with this:

enter image description here

For reasons which are probably irrelevant, I need to group a set of these shapes together such that what I'll end up dealing with is this:

enter image description here

In this case I would end up with something like this:

enter image description here

However, the possible combinations of these shapes is vast, and I can end up with something more complicated like this:

enter image description here

Where I would end up with something like:

enter image description here

Note in the last example I didn't remove the lines for the shapes I grouped together, but fundamentally it's the same idea as the first example. The ones still touching are logically grouped, so I would imagine that I can treat them as a single shape. You can see from this that the configuration can get complex quickly. Perhaps I'm overthinking the issue, but this is the idea.

2

There are 2 best solutions below

6
On BEST ANSWER

Here is one suggestion that may work if the polygons are convex (1): scale the whole figure by some (small) factor of increase - perhaps $10\%$, so $1.1$. The polygons will still touch one another. Now shrink each polygon "in place" by a factor of $0.9$, using a center chosen inside each (perhaps the centroid). Then the polygons will be the same size as in the original, but spread out.

You can adjust the stretch/shrink factor to meet your aesthetic goals.

Consider editing the question to show us a picture of what you start with and what you might be pleased to end up with.

(1) The comment saying they may not be convex means this method might not work. All the more reason to show us a picture or two of what you need.

3
On

In general, this is not always possible with concave polygons. A simple example:

enter image description here