I'm trying to figure out how to shrink a polygon using only the coordinates of its corners. For example, if I have the following shape with corners at [(0, 0), (0, 100), (20, 100), (30, 60), (40, 100), (60, 100), (60, 0), (40, 10), (40, 40), (20, 40), (20, 10)] so the shape looks like this:
And I want to find the corner coordinates for if I shrink this polygon by some width and height factor. For example, If I want to shrink its width by 10% and height by 20% then this could be shown as something like this:
I originally asked this on StackOverflow, and it was suggested that this can be easily solved with analytic geometry. I don't know any analytic geometry, so I'm not sure where to start with solving this problem. Is there a straightforward way to do this?



It's clear that if we figure out where each vertex goes, we should be able to retrace the structure.
To begin, let's compute the centers of mass of the left polygonal block, pretending there is an edge $(20,100) \to (20, 40)$ and the right polygonal block, pretending there is an edge $(40,100) \to (40, 40)$, and let's also compute the center of mass of the middle structure. Call these centers of mass $L, R,$ and $C$, respectively.
The vertices on the outer edges $x=0$ would shrink towards $L$, and vertices at $x=60$, -- towards $R$. Perhaps the middle vertices can shrink towards the center of mass of the entire structure, but that would mean the vertex at $(20, 100)$ will shift right, not left as you have drawn it. Not sure if this is the desired behavior or not.
If not, you can move the points at $x=20$ towards $L$ and and $x=40$ towards $R$.
In either case, you will shrink $(30,60)$ towards $C$.
We now reduced this to shrinking a convex polygon to it's center of mass, please let me know if you need any help with that problem in the comments.