1
$\begingroup$

My task is to transform the cube from the left corner to the big cube in the middle:

What I did was:

First i scale the cube:

$$ \begin{pmatrix} 4 & 0 & 0 \\ 0 & 4 & 0 \\ 0 & 0 & 1 \\ \end{pmatrix} $$

Next i rotate it $45^\circ$:

$$ \begin{pmatrix} \cos(45^\circ) & -\sin(45^\circ) & 0 \\ \sin(45^\circ) & \cos(45^\circ) & 0 \\ 0 & 0 & 1 \\ \end{pmatrix} $$

And last i translate the cube:

$$ \begin{pmatrix} 1 & 0 & 10 \\ 0 & 1 & 7 \\ 0 & 0 & 1 \\ \end{pmatrix} $$

When i combine this matrices i get my transformation matrix:

$$ \begin{pmatrix} 4\cos(45^\circ) & -4\sin(45^\circ) & 40\cos(45^\circ) - 28\sin(45^\circ) \\ 4\sin(45^\circ) & 4\cos(45^\circ) & 40\cos(45^\circ) + 28\sin(45^\circ) \\ 0 & 0 & 1 \\ \end{pmatrix} $$

But then i tried to apply this matrix to the point $(0,1,1)$ and i got an wrong result:

$$(5.6, 50.9116 ,1)$$

As you can see it should be around:

$$(7.1, 9.9, 1)$$

What did I wrong? Thanks!

$\endgroup$
5
  • $\begingroup$ Better to tell us how you are going to implement these matrices on each point especially for transform matrix. $\endgroup$
    – Arashium
    Feb 1 '15 at 10:02
  • $\begingroup$ @Arashium I take one point for example (1,1,1) and multiply it with my transformation-matrix! $\endgroup$
    – John Smith
    Feb 1 '15 at 10:04
  • $\begingroup$ oop, translation matrix. is it $x=x+T$ or $x=T\times x$? $\endgroup$
    – Arashium
    Feb 1 '15 at 10:06
  • $\begingroup$ I would say $x = T x X$ $\endgroup$
    – John Smith
    Feb 1 '15 at 10:08
  • $\begingroup$ But $$ \begin{pmatrix} 1 & 0 & 10 \\ 0 & 1 & 7 \\ 0 & 0 & 1 \\ \end{pmatrix} $$ * (1,1,1) = (10,7,1) $\endgroup$
    – John Smith
    Feb 1 '15 at 10:13
1
$\begingroup$

There is a mistake in your multiplication.

$$ T_{total}=\begin{pmatrix} 4\cos(45^\circ) & -4\sin(45^\circ) & 40\cos(45^\circ) - 28\sin(45^\circ) \\ 4\sin(45^\circ) & 4\cos(45^\circ) & \color{red}{28\cos(45^\circ) + 40\sin(45^\circ)} \\ 0 & 0 & 1 \\ \end{pmatrix} $$

But, since $sin (45^\circ)$ and $cos (45^\circ)$ have the same value, the problem is not from this point.

The problem is related to the order of the Transforms. In matrix multiplication, you should care about matrix order.

$T1$ is scale transform

$T2$ is rotation transform

$T3$ is translation transform

you computed:

$$X_{new}=(T1 \times T2 \times T3) \times X_{old}$$

while, you need to scale first then rotation then translation:

$$X_{new}=(T3 \times T2 \times T1) \times X_{old}$$

$$T3 \times T2 \times T1=\begin{pmatrix} 4\cos(45^\circ) & -4\sin(45^\circ) & 10 \\ 4\sin(45^\circ) & 4\cos(45^\circ) & 7 \\ 0 & 0 & 1 \\ \end{pmatrix}$$

$$T1\times T2 \times T3 \times \begin{pmatrix} 0 \\ 1 \\ 1 \\ \end{pmatrix}=\begin{pmatrix} 5.66 \\ 50.91 \\ 1 \\ \end{pmatrix}$$

While

$$T3\times T2 \times T1 \times \begin{pmatrix} 0 \\ 1 \\ 1 \\ \end{pmatrix}=\begin{pmatrix} 7.17 \\ 9.83 \\ 1 \\ \end{pmatrix}$$

$\endgroup$
2
  • $\begingroup$ Thanks Arashium! But I didnt't understand what I should do instead? $\endgroup$
    – John Smith
    Feb 1 '15 at 11:24
  • $\begingroup$ See my update.... $\endgroup$
    – Arashium
    Feb 1 '15 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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