I am an undergraduate student, and today I was given two triangles, $T_1$ (green) and $T_2$ (blue) in $R^2$:
I was then asked to find the transformation matrix transforming $T_1$ to $T_2$. What I understand from this is, that I need to find $F$ in the following matrix equation:
$T_2 = F \cdot T_1$.
where
$T_1= \begin{bmatrix}2&6&8\\2&-2&6\end{bmatrix}$
$T_2= \begin{bmatrix}-2&-10&-14\\-2&-4&10\end{bmatrix}$
which are the coordinates of the corners of the triangles.
The above matrix equation however, is inconsistent, so how can I find $F$?
It has to be a linear mapping, not an affine one.
Have tried a lot, any help greatly appreciated!
$\endgroup$ 54 Answers
$\begingroup$Organize each of the points of the starting triangle as columns in a matrix $\mathbf{U}$, and each of the points of the resulting triangle as columns in a matrix $\mathbf{V}$. Thus, both $\mathbf{U}$ and $\mathbf{V}$ are $3\times3$ matrices because you have 3 vertices, each vertex having 3 coordinates. I am assuming the triangles are contained in $\mathbb{R}^3$ space.
If your triangles are in $\mathbb{R}^2$ (as is your case, since they are in the plane), you should use "0 0 1" as the last row for each of the $\mathbf{U}$ and $\mathbf{V}$ matrices so that they are not singular.
Now, assume there is a matrix $\mathbf{T}$ such that $\mathbf{T}\mathbf{U}=\mathbf{V}$. All you need to do is to isolate $\mathbf{T}$:
$$ \mathbf{T}\mathbf{U}\mathbf{U}^{-1}=\mathbf{V}\mathbf{U}^{-1}\\ \mathbf{T}=\mathbf{V}\mathbf{U}^{-1} $$
And you can transform any point now using $\mathbf{T}$, including each of the three vertices of the starting triangle. Say you have a point $p=[x\ y\ z]^T$ in the starting triangle frame of reference (given by the $\mathbf{U}$ matrix), then you get a point $p^\prime=[x^\prime\ y^\prime\ z^\prime]^T$ in the resulting triangle frame of reference (given by the $\mathbf{V}$ matrix):
$$ \mathbf{T}p=\mathbf{V}\mathbf{U}^{-1}p=p^\prime $$
If your triangles were in the plane, you just ignore the trasformed z coordinate, $z^\prime$.
Using the vertices of the triangles as columns in $\mathbf{U}$ and $\mathbf{V}$ is just a convenient way of writing the problem in matrix form.
$\endgroup$ 1 $\begingroup$The vertices of $T_1$ are $(2,2)$, $(6,-2)$, and $(8,6)$. The vertices of $T_2$ are $(-2,-2)$, $(-10,-4)$, and $(-14,10)$. We want a transformation mapping $T_1$ to $T_2$. So the vertices of $T_1$ must map to the vertices of $T_2$. Let's factor out the 2 to save us some trouble. We seek a linear transformation $L:\mathbb{R}^2 \to \mathbb{R}^2$ with $$\{(1,1), (3,-1), (4,3)\} \mapsto \{(-1,-1), (-5,-2), (-7,5)\} $$ The map $L$ is determined by its action on the two linearly independent vectors $(1,1)$ and $(4,3)$. It must map them to two of the vectors in $\{(-1,-1), (-5,-2), (-7,5)\}$. Using this we can easily calculate a matrix.
For example, the matrix mapping $(1,1) \mapsto (-1,-1)$ and $(4,3) \mapsto (-5,-2)$ is $$ \begin{pmatrix} -2 & 1 \\ 1 & -2 \end{pmatrix}. $$ This matrix also happens to map $(3,-1)$ to the remaining vector $(-7,5)$ and so we are done. We got lucky this time; if this hadn't mapped to the right vector we could have kept choosing different pairs of vectors until we found the correct map.
$\endgroup$ 2 $\begingroup$Another way to get the answer is to notice that you can map $T_1$ to $T_2$ by reflecting $T_1$ in the origin and then scaling the result by 3 with respect to the diagonal $x=y$. Reflecting in the origin is simply $(x,y)\mapsto (-x,-y)$ and scaling is given by $(x,y)\mapsto(x+(x-y),y-(x-y))$.
Incidentally, the formula for scaling $(x,y)$ by $\gamma$ with respect to a line defined by $ax+by+d=0$ is
$$x\mapsto x+(\gamma-1)\frac{a(ax+by+d)}{(a^2+b^2)}\quad \text{and}\quad y\mapsto y+(\gamma-1)\frac{b(ax+by+d)}{(a^2+b^2)}.$$
If $(x,y)$ is at the distance $r$ from the line, then after it is scaled by $\gamma$ it will be at the distance $\gamma r$ from the line.
$\endgroup$ $\begingroup$$\newcommand{\+}{^{\dagger}}% \newcommand{\angles}[1]{\left\langle #1 \right\rangle}% \newcommand{\braces}[1]{\left\lbrace #1 \right\rbrace}% \newcommand{\bracks}[1]{\left\lbrack #1 \right\rbrack}% \newcommand{\dd}{{\rm d}}% \newcommand{\isdiv}{\,\left.\right\vert\,}% \newcommand{\ds}[1]{\displaystyle{#1}}% \newcommand{\equalby}[1]{{#1 \atop {= \atop \vphantom{\huge A}}}}% \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}% \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}% \newcommand{\ic}{{\rm i}}% \newcommand{\imp}{\Longrightarrow}% \newcommand{\ket}[1]{\left\vert #1\right\rangle}% \newcommand{\pars}[1]{\left( #1 \right)}% \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}} \newcommand{\pp}{{\cal P}}% \newcommand{\root}[2][]{\,\sqrt[#1]{\,#2\,}\,}% \newcommand{\sech}{\,{\rm sech}}% \newcommand{\sgn}{\,{\rm sgn}}% \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}} \newcommand{\ul}[1]{\underline{#1}}% \newcommand{\verts}[1]{\left\vert #1 \right\vert}% \newcommand{\yy}{\Longleftrightarrow}$
We just need a symmetric $3 \times 3$ real matrix $F$ where $F$ satisfy $F{\bf P}_{i} = {\bf P}_{i}'$. $i = 1, 2, 3$. ${\bf P}_{i}$ and ${\bf P}_{i}'$ are the triangle vertices "before" ( one of them ) and "after" ( the other one ) the transformation generated by the matrix $F$. With the vectors $$ {\bf 1} \equiv \pars{\begin{array}{c}1 \\ 0 \\ 0\end{array}}\,, \qquad {\bf 2} \equiv \pars{\begin{array}{c}0 \\ 1 \\ 0\end{array}}\,, \qquad {\bf 3} \equiv \pars{\begin{array}{c}0 \\ 0 \\ 1\end{array}} $$ The $F$ matrix elements $F_{ij} \equiv {\bf i}^{\sf T}F\,{\bf j}$ become $$ \color{#0000ff}{\large F_{ij}} = {\bf i}^{\sf T}F\sum_{\ell = 1, 2, 3}{\bf P}_{\ell}{\bf P}_{\ell}^{\sf T}\,{\bf j} = \color{#0000ff}{\large{\bf i}^{\sf T}\,\pars{\sum_{\ell = 1, 2, 3} {\bf P}_{\ell}'{\bf P}_{\ell}^{\sf T}}\,\,{\bf j}} $$
Notice that this is the ${\large\tt 3D}$ result but the idea can be straightforward 'translated' to ${\large\tt 2D}$.
$\endgroup$