# How to find an affine map for given points

I am trying to understand affine maps. In the book I am using there is the following example, which I don't understand. Given are the following points: \begin{array}{lll} p_0 = \begin{pmatrix} 1 \\ 1 \end{pmatrix}, & p_1 = \begin{pmatrix} 1 \\ 2 \end{pmatrix}, & p_2 = \begin{pmatrix} 0 \\ 1 \end{pmatrix}, \\ q_0 = \begin{pmatrix} -2 \\ -1 \end{pmatrix}, & q_1 = \begin{pmatrix} \phantom{-}0 \\ -1 \end{pmatrix}, & q_2 = \begin{pmatrix} -2 \\ -2 \end{pmatrix}. \end{array}

Then the following vectors are computed \begin{array}{ll} \overrightarrow{p_0 p_1} = \begin{pmatrix} 0 \\ 1 \end{pmatrix}, & \overrightarrow{p_0 p_2} = \begin{pmatrix} -1 \\ \phantom{-}0 \end{pmatrix}, \\ \overrightarrow{p_0 p_1} = \begin{pmatrix} 2 \\ 0 \end{pmatrix}, & \overrightarrow{p_0 p_1} = \begin{pmatrix} \phantom{-}0 \\ -1 \end{pmatrix}. \end{array}

I am asked to find an affine map such that $f(p_{i})=q_{i}$.

It now says that the matrix of the map determined by $F(\overrightarrow{p_0 p_i})=\overrightarrow{q_0 q_i}$, $i=1,2$ is given by $$A = \begin{pmatrix} 0 & 2 \\ 1 & 0 \end{pmatrix}.$$

I don't understand how I get this matrix. I would say it is the following one, but I guess I am wrong. I did everything with repect to the bases $\{(0,1),(-1,0)\}$ and $\{(1,0),(0,1)\}$. I am not sure about the second basis, but since there is no other basis mentioned I thought it is the one the author has used too. $$\begin{pmatrix} 2 & \phantom{-}0 \\ 0 & -1 \\ \end{pmatrix}$$

Unfortunately I don't know where I making the mistake.

I would really appreciate some help. Thanks a lot in advance!

• $A$ represents only the linear part of the affine map. You can’t represent a map of the plane to itself that includes a translation as a $2\times2$ matrix.
– amd
Commented Aug 23, 2018 at 18:06
• Is your second set of vectors actually $\overrightarrow{q_0q_1}$ and $\overrightarrow{q_0q_2}$?
– amd
Commented Aug 23, 2018 at 18:09

Relative to the bases that you chose to use, the matrix that you computed is in fact correct. Generally speaking, however, when specific bases aren’t mentioned the standard basis is implied. Indeed, if you apply a change of basis to the matrix that you computed, you get the correct answer: $$\begin{bmatrix}2&0\\0&-1\end{bmatrix} \begin{bmatrix}0&-1\\1&0\end{bmatrix}^{-1} = \begin{bmatrix}0&2\\1&0\end{bmatrix}.$$ (No change-of-basis matrix is needed on the left side because you already used the standard basis for the codomain.)

You could have constructed this matrix directly by taking advantage of the fact that its columns are the images of the basis vectors: we know that $(0,1)^T\mapsto(2,0)^T$ and, by linearity, $(1,0)^T\mapsto(0,1)^T$, so those are the second and first columns, respectively, of the transformation matrix (with respect to the standard basis).

Let $A= \begin{pmatrix} a & b \\ c & d \\ \end{pmatrix}$

Now, apply this matrix to your vectors $p_0p_1$ and $p_0p_2$

The first one gives:

$q_0q_1=A*p_0p_1$

So $\begin{pmatrix}2 \\0 \end{pmatrix}=A* \begin{pmatrix}0 \\1 \end{pmatrix} = \begin{pmatrix} a*0 + b*1 \\ c*0 +d*1\\ \end{pmatrix}= \begin{pmatrix}b \\d \end{pmatrix}$

This gives you $b=2$ and $d=0$. You can use the other equation to get a and c.

There is a neat formula for your case $$\vec{f}(x; y) = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{q_0} & \vec{q_1} & \vec{q_2} \\ x & p_0^x & p_1^x & p_2^x \\ y & p_0^y & p_1^y & p_2^y \\ 1 & 1 & 1 & 1 \\ \end{pmatrix} }{ \det \begin{pmatrix} p_0^x & p_1^x & p_2^x \\ p_0^y & p_1^y & p_2^y \\ 1 & 1 & 1 \\ \end{pmatrix} },$$ where $$x$$ and $$y$$ are coordinates of the point you are mapping.

Here's how it works (plugging in initial points) $$\vec{f}(x; y) = (-1) \frac{ \det \begin{pmatrix} 0 & \vec{q_0} & \vec{q_1} & \vec{q_2} \\ x & 1 & 1 & 0 \\ y & 1 & 2 & 1 \\ 1 & 1 & 1 & 1 \\ \end{pmatrix} }{ \det \begin{pmatrix} 1 & 1 & 0 \\ 1 & 2 & 1 \\ 1 & 1 & 1 \\ \end{pmatrix} } = (\vec{q}_0 - \vec{q}_2) x + (\vec{q}_1 - \vec{q}_0) y + (\vec{q}_0 - \vec{q}_1 + \vec{q}_2) =$$ now I plug in the final points $$= \left[ \begin{pmatrix} -2 \\ -1 \end{pmatrix} - \begin{pmatrix} -2 \\ -2 \end{pmatrix} \right] x + \left[ \begin{pmatrix} 0 \\ -1 \end{pmatrix} - \begin{pmatrix} -2 \\ -1 \end{pmatrix} \right] y + \left[ \begin{pmatrix} -2 \\ -1 \end{pmatrix} - \begin{pmatrix} 0 \\ -1 \end{pmatrix} + \begin{pmatrix} -2 \\ -2 \end{pmatrix} \right]$$ Simplification yields $$\vec{f}(x; y) = \begin{pmatrix} 0 \\ 1 \end{pmatrix} x + \begin{pmatrix} 2 \\ 0 \end{pmatrix} y + \begin{pmatrix} -4 \\ -2 \end{pmatrix}$$ Or you can write that in canonical form $$\vec{f}(x; y) = \begin{pmatrix} 0 & 2 \\ 1 & 0 \end{pmatrix} \begin{pmatrix} x \\ y \end{pmatrix} + \begin{pmatrix} -4 \\ -2 \end{pmatrix}.$$ Now you can easily check that $$\vec{f}(1;1) = \begin{pmatrix} -2 \\ -1 \end{pmatrix};~ \vec{f}(1;2) = \begin{pmatrix} 0 \\ -1 \end{pmatrix};~ \vec{f}(0;1) = \begin{pmatrix} -2 \\ -2 \end{pmatrix}.$$

For more details on how this all works you may check "Beginner's guide to mapping simplexes affinely", where authors of the equation I used elaborate on theory behind it. In the guide there is exactly the same 2D example solved as the one you are interested in.

The same authors recently published "Workbook on mapping simplexes affinely". There are many examples of different problems you can solve with this equation.