1

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.

Mark W
  • 113
  • 1
    Pick a central point and translate each polygon proportionately to how far away it is from the center. – Donald Splutterwit Nov 15 '19 at 21:12
  • @DonaldSplutterwit I'm not convinced it will be that simple, but perhaps it is. The nature of the polygons is such that it can create convex/concave polygons which might create interlocking shapes... if you follow me there. – Mark W Nov 15 '19 at 21:15
  • Pick a central point in each polygon and calculate their new positions ... then recalculate each point of the original polygon relative to its new center. ... Should be a doddle ? – Donald Splutterwit Nov 15 '19 at 21:18
  • "These polygons are all touching in some way": what do you mean ? –  Nov 15 '19 at 21:23
  • 1
    "line segments / arcs": so they aren't polygons ?? –  Nov 15 '19 at 21:23
  • 2
    I agree with @DonaldSplutterwit. For your edification, such a transformation is called a homothety ("ho MOTH a tee") and the point you pick is called the "homothetic center." https://en.wikipedia.org/wiki/Homothetic_transformation – David G. Stork Nov 15 '19 at 21:30
  • @DavidG.Stork I love links. Much appreciated. – Mark W Nov 15 '19 at 21:37
  • @YvesDaoust I suppose they wouldn't be with the arcs, 'shapes' if you prefer? – Mark W Nov 15 '19 at 21:39

2 Answers2

1

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.

Ethan Bolker
  • 95,224
  • 7
  • 108
  • 199
  • I can guarantee that the hull of the collection of polygons will be convex, I cannot however guarantee that the individual polygons will be. I can attach some pictures sure. – Mark W Nov 15 '19 at 21:19
  • This is the same proposal as DonaldSplutterwit's. –  Nov 15 '19 at 21:41
  • I have provided some crude drawings. – Mark W Nov 15 '19 at 21:45
  • @YvesDaoust Essentially, yes. I was writing it while he was writing his comment. – Ethan Bolker Nov 15 '19 at 21:45
  • I think this is the way to go. I'll begin implementing this. I appreciate the help and guidance guys! – Mark W Nov 15 '19 at 21:54
  • Maybe it is possible to build a "repelling algorithm" where each piece repells its neighbours with a certain activity threshold... – Jean Marie Nov 15 '19 at 22:31
1

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

enter image description here

  • I had not considered this. – Mark W Nov 15 '19 at 21:40
  • After considering this, I don't actually think something like this would be possible given the constraints of how the configurations are made. I can end up with a convex shape like an L possibly... but I'm beginning to doubt that I'll en up with something like the shape above. I think that the Homothetic translation is the way to go. – Mark W Nov 15 '19 at 21:52
  • @MarkW: this is why we needed more info about those "shapes". –  Nov 15 '19 at 22:00