[Math] Calculate rectangle position after scaling from his center

geometrytransformation

I have a rectangle with these bounds

height: 31.010414123535156
width: 215.8330078125
x: 10.95849609375
y: 90.49478912353516

I want to scale up the rectangle by a 0.541667 factor.
X, Y coordinates are coordinates of the top left corner.

I know that the scale origin is the center of the rectangle.

To find the width and height I simply did this calculate

newWidth = width / 0.541667
newHeight = height / 0.541667

But I can't figure out how to calculate the new x and y coordinates.

Which gives me these bounds

height: 57.25
width: 398.4609375
x: -80.35546875 //how to find this value ?
y: 77.375 //how to find this value ?

Best Answer

Your results make sense only if your $x$-axis goes from left to right, $y$-axis goes from top to bottom and $(x,y)$ denotes the coordinate of the top left corner of the rectangle. Such coordinate system is typically used for computer screens. In that case:

newX = x + width/2 - newWidth/2
newY = y + height/2 - newHeight/2

Check your values and you'll see that the numbers match.

Related Question