# Translation, Scaling and Rotation of Matrix

Two 2D house models A and B are shown in the figure below. House A has one point at (3,2) and House B has one point at (0,-1).

Calculate a chain of matrices that, when post-multiplied by the vertices of House A, will transform all the vertices of House A into the vertices of House B, i.e. translate and rotate the house point (3,2) to (0,-1). The transformation must also scale the size of House A by half to House B. My Attempt

First we need to move House A to the origin so we use the translation matrix.

$$\begin{matrix} 1 & 0 & -3 \\ 0 & 1 & -2 \\ 0 & 0 & 1 \\ \end{matrix}$$

Then we have to scale it down by half as per the requirement in the question.

$$\begin{matrix} 1/2 & 0 & 0 \\ 0 & 1/2 & 0 \\ 0 & 0 & 1 \\ \end{matrix}$$

Then I rotate it clockwise

$$\begin{matrix} 0 & 1 & 0 \\ -1 & 0 & 0 \\ 0 & 0 & 1 \\ \end{matrix}$$

Then I translate it from the origin to the House B

$$\begin{matrix} 1 & 0 & 0 \\ 0 & 1 & -1 \\ 0 & 0 & 1 \\ \end{matrix}$$

Finally I multiply all of these matrices together with our original matrix

$$\begin{matrix} 3 \\ 2 \\ 1 \\ \end{matrix}$$

The only problem is, I don't get (0,-1). Instead I get (1,-1.5) which leads me to believe I have done something wrong. I have used a matrix calculator so I know my math is correct so one or more of my matrices are wrong.

## 1 Answer

In the homogeneous coordinates that you wrote the matrices for, the tip of House A is represented by $(3,2,1)$, not $(3,2,0)$. If you use that, you get $(0,-1,1)$ as expected.

• Whoops, missed that. I checked my calculations again but still the answer is not coming out as expected. – TheRapture87 May 6 '16 at 18:02
• @Aceboy1993: The first multiplication yields $(0,0,1)$, and that remains invariant until the last multiplication transforms it into $(0,-1,1)$. – joriki May 6 '16 at 18:04
• Maybe I'm misunderstanding, but the first multiplication I did was Translation x Scale which yields a 3x3 matrix not (0,0,1) – TheRapture87 May 6 '16 at 18:09
• @Aceboy1993: I see -- I was multiplying the vector with the matrices one by one. Then it sounds like the problem is that you're multiplying the matrices in the wrong order. Translation is applied first, then scaling, so if you form the product of the matrices, you need the scaling matrix times the translation matrix, not the other way around. – joriki May 6 '16 at 18:11
• Ok perfect, I managed to get the answer!!! The order like you said was the issue. Thanks for the patience. Much appreciated! – TheRapture87 May 6 '16 at 18:45