# How do I properly horizontally scale a rectangle in 2-D space?

I'm a programmer trying to remember math stuff. I think this is right.

I have a rectangle in 2D space. I want to scale it around a certain point inside of the rectangle, but not necessarily the center. Let's call it x,y. I think I have to create a transformation matrix to do this properly. So here's what I came up with:

• Translate by -x (to move x to the origin)
• Scale by the scale factor
• Translate by x, to "move back"

So now I've put that into a Transformation matrix (I'm doing this in a programming language, so I think that the order is correct). But, when I multiply the transformation matrix by the origin of the rectangle, I get what I think is the wrong result.

Am I totally barking up the wrong tree here?

-

If your point is $(x,y)$ and the corners of the rectangle are $(x_1,y_1)$ and $(x_2,y_2)$ is what you want a rectangle of the same shape with $(x,y)$ in the same relative position? If so, and the scale factor is $r$, you just want $x'_1=r(x_1-x)+x$ and similarly for the other coordinates.