[Math] Polygon Equal Edge Offsetting

algorithmscomputational geometrygeometrypolygons

If I have a random polygon of any complexity, be it a square or an irregular 20 sided polygon, how can I scale this up?

I know the coordinates of each point on the polygon, but that is all.

Another requirement is that as the polygon is scaled up, each side must be an equal distance from its original smaller counterpart. Unlike if you were to directly upscale a rectangle for example, where two sides would be more distant than the other two.

Any help would be greatly appreciated, thanks.

EDIT:

You can see in the demonstration image below, the top rectangles are directly scaled, 1:1. I want to achieve the bottom rectangle scaling, keeping equal distance. How might it be possible to calculate the new x,y coords of the scaled up polygon?

enter image description here

EDIT 2:

I have been corrected, I should be referring to Polygon Offsetting (not scaling!).

Best Answer

This is called polygon offsetting rather than scaling.

In the general case, this is much harder than it seems, as different parts of the inflated polygon can overlap each other, letting holes appear, and some edges may completely disappear. The way to handle corners isn't so well defined either.

For an exact solution, have a look at Clipper.

For a simple solution not guaranteed to work on all shapes, you have to consider all vertices in turn, draw lines parallel to the abutting edges, at the desired distance on the right side, and find their intersection.

enter image description here

Related Question