Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

This is essentially what you describe, so it should work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.