Search code examples
algorithm2dscale

How to scale a shape made of points?


Say I have a shape like this:

larger shape

And I want to scale it down to this:

smaller shape

How do I calculate the location of the points (red circles) to do so?


Solution

  • new.x = scale * (old.x - center.x) + center.x
    new.y = scale * (old.y - center.y) + center.y
    

    Repeat for each point.