0
$\begingroup$

I have two triangles with these corner points:

$$ A= \left[ {\begin{array}{cc} 0 & -0.5 & 1\\ 0 & 0.5 & 1\\ \end{array} } \right] $$ $$ B= \left[ {\begin{array}{cc} 1.5 & 2 & 2.5\\ 0.5 & 1 & -0.5\\ \end{array} } \right] $$ They look like this when plotted. enter image description here

I have to transform triangle B to triangle A.

I did this by:

  1. $T_1$ = Translating B to the origin.
  2. $R_1$ = Rotating B 90 degree counter clockwise.
  3. $T_2$ = Translate B to the same coordinates as A.

Now I want to combine all these operations into one matrix S however I am not sure how this can be done. Is it just S = $T_1 * R_1 * T_2$?

$$ T_1= \left[ {\begin{array}{cc} 1 & 0 & -2\\ 0 & 1 & 0\\ 0 & 0 & 1\\ \end{array} } \right] $$

$$ R_1= \left[ {\begin{array}{cc} 0 & -1 & 0\\ 1 & 0 & 0\\ 0 & 0 & 1\\ \end{array} } \right] $$

$$ T_2= \left[ {\begin{array}{cc} 1 & 0 & 1\\ 0 & 1 & 0.5\\ 0 & 0 & 1\\ \end{array} } \right] $$

$$ S_1 = T_1 * R_1= \left[ {\begin{array}{cc} 0 & -1 & 0\\ 1 & 0 & 0\\ 0 & 0 & 0\\ \end{array} } \right] $$

$$ S = S_1 * T_2= \left[ {\begin{array}{cc} 0 & 0 & -1\\ 1 & 0 & 1\\ 0 & 0 & 0\\ \end{array} } \right] $$

but then

$$ A = S * B= \left[ {\begin{array}{cc} -1 & -1 & -1\\ 2.5 & 3 & 3.5\\ 0 & 0 & 0\\ \end{array} } \right] $$

is wrong.

$\endgroup$
1
  • $\begingroup$ Once you’ve verified that the corresponding vertices in each matrix match up, you can compute the transformation matrix directly from $A$ and $B$: Add a row of $1$s to the bottom each to form $A'$ and $B'$. The required transformation matrix is then $A'B'^{-1}$. $\endgroup$
    – amd
    Sep 23, 2019 at 0:35

2 Answers 2

0
$\begingroup$

I assume that you're writing your points using homogeneous coordinates, vertically, i.e., the points $(x, y)$ is written $\pmatrix{x\\y\\1}$, and that your matrices operate on the left, i.e., you take a point $P$ and compute $MP$ (where $M$ is the matrix). It sure looks like it from the entries in your matrices.

In that case, the matrix you need is $$ M = T_2 \cdot R_1 \cdot T_1, $$ because when you multiply this by a point $P$, you compute \begin{align} M\cdot P &= (T_2 \cdot R_1 \cdot T_1)\cdot P\\ &= (T_2 \cdot R_1) (\cdot T_1 \cdot P)\\ \end{align} where the thing in the last parens gives you the coordinates of $P$ after the first translation. Continuing, \begin{align} M\cdot P &=(T_2 \cdot R_1) (\cdot T_1 \cdot P)\\ &=T_2 \cdot (R_1 \cdot (\cdot T_1 \cdot P))\\ \end{align} where the thing in the larger parens on the right is the coordinates of the translated point, after rotation. And finally, the entire right hand side is the result of all three operations, analogously.

$\endgroup$
0
$\begingroup$

Yes, when you multiply matrices you are basically having one of them operate on the other/s. For example, in the case of $A*B$ you have $A$ operating on $B$. Hope that helps.

$\endgroup$
3
  • $\begingroup$ Thank you but I always get the wrong result. $\endgroup$
    – Simon
    Sep 22, 2019 at 17:53
  • 1
    $\begingroup$ Hey, I think you are getting the order of operations wrong. In your case it would be $T_2*R_1*T_1$ since you are first translating with T_1 then you are operating on that with the transformation/matrix $R_1$ ( giving $R_1*T_1$) and then $T_2$ (giving $T_2*R_1*T_1$). Hope that helps if you need more help met me know. $\endgroup$ Sep 22, 2019 at 18:09
  • $\begingroup$ Thank you again, I fixed it by translating directly to the origin with one corner point and therefore I could cancel one translation $\endgroup$
    – Simon
    Sep 22, 2019 at 20:48

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.