Find any affine transformation that swaps affine lines The task is to find any affine transformation that will swap the following two lines:
$$L_1:(1,1,1) + span((1,0,2))$$
$$L_2:(1,0,1) + span((1,0,-1))$$
From what I understand there is a number of equations I can make:
$$f((1,1,1))=(1,0,1)$$
$$f((1,0,1))=(1,1,1)$$
I am not sure how to create the other two equations that I need.
I also understand that an affine transformation consists of a linear transformation and a translation.
Does this translation have to be $(1,1,1) - (1,0,1)$ or what else could it be.
I'm really confused by the affine transformations.
 A: I think the key observation is that an affine transformation will take lines to lines.  As a line is determined by two points, the image of a line is determined by the images of any two points on it. This will yield 4 equations that determine a 3x3 matrix (the linear transformation) and a translation. You may find the computations easier if you first translate the lines so that one of them passes through the origin. 
A: To swap 2 lines it seems sufficient to find transformation that swaps pairs of points each line passes through. At the same time you may see, there are many such transformations as our choice of points is arbitrary. As you ask for any transformation, let me arbitrarily choose points $(1,1,1)^T$ and $(2,1,3)^T$ on $L_1$ and points $(1,0,1)^T$ and $(2,0,0)^T$ on $L_2$. Now I need transformation that maps
$$A: \begin{pmatrix} 1\\ 1\\ 1 \end{pmatrix} 
   \rightarrow 
   \begin{pmatrix} 1\\ 0\\ 1 \end{pmatrix};~A: \begin{pmatrix} 2\\ 1\\ 3 \end{pmatrix} 
   \rightarrow 
   \begin{pmatrix} 2\\ 0\\ 0 \end{pmatrix};~A: \begin{pmatrix} 1\\ 0\\ 1 \end{pmatrix} 
   \rightarrow 
   \begin{pmatrix} 1\\ 1\\ 1 \end{pmatrix};~A: \begin{pmatrix} 2\\ 0\\ 0 \end{pmatrix} 
   \rightarrow 
   \begin{pmatrix} 2\\ 1\\ 3 \end{pmatrix}.
$$
I will use general approach from "Beginner's guide to mapping simplexes affinely" and "Workbook on mapping simplexes affinely" to solve the latter problem. It is shown there, the transformation can be presented as
$$
\vec{A}(\vec{x}) =
(-1)
\frac{
    \det
    \begin{pmatrix}
        0 & (1,0,1)^T & (2,0,0)^T & (1,1,1)^T & (2,1,3)^T \\
        \begin{matrix}
            x_{1} \vphantom{x_{1}^{(1)}} \\
            x_{2} \vphantom{x_{1}^{(1)}} \\
            x_{3} \vphantom{x_{1}^{(1)}} \\
        \end{matrix} &
%
        \begin{matrix}
            1  \\
            1  \\
            1  \\
        \end{matrix} &
%
        \begin{matrix}
            2  \\
            1  \\
            3  \\
        \end{matrix} &
%
        \begin{matrix}
            1  \\
            0  \\
            1  \\
        \end{matrix} &
%
        \begin{matrix}
            2 \\
            0 \\
            0 \\
        \end{matrix} \\
%
        1 & 1 & 1 & 1 & 1
    \end{pmatrix}
}{
    \det
    \begin{pmatrix}
        \begin{matrix}
            1 \\
            1 \\
            1 \\
        \end{matrix} &
%
        \begin{matrix}
            2 \\
            1 \\
            3 \\
        \end{matrix} &
%
        \begin{matrix}
            1 \\
            0 \\
            1 \\
        \end{matrix} &
%
        \begin{matrix}
            2 \\
            0 \\
            0 \\
        \end{matrix} \\
%
        1 & 1 & 1 & 1
    \end{pmatrix}
}.
$$
Doing determinants I get
$$
= \begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix}
  \frac{2 - x_1 +  3 x_2 - x_3}{3} +
  \begin{pmatrix} 2 \\ 0 \\ 0 \end{pmatrix}
  \frac{x_1 + x_3 - 2}{3} +
  \begin{pmatrix} 1 \\ 1 \\ 1 \end{pmatrix}
  \frac{4 - 2 x_1 - 3 x_2 + x_3}{3} +
  \begin{pmatrix} 2 \\ 1 \\ 3 \end{pmatrix}
  \frac{2 x_1 - x_3 - 1}{3}
$$
or simplified
$$
\vec{A}(\vec{x}) =
    \begin{pmatrix} 1 \\ 0 \\ 1 \end{pmatrix} x_1 + 
    \begin{pmatrix} 0 \\ -1 \\ 0 \end{pmatrix} x_2 + 
    \begin{pmatrix} 0 \\ 0 \\ -1 \end{pmatrix} x_3 +
    \begin{pmatrix} 0 \\ 1 \\ 1 \end{pmatrix}
$$
or in canonical form
$$
\vec{A}(\vec{x}) =
    \begin{pmatrix} 1 & 0 & 0 \\ 
                    0 & -1 & 0 \\
                    1 & 0 & -1 \end{pmatrix} 
    \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} +
\begin{pmatrix} 0 \\ 1 \\ 1 \end{pmatrix}.
$$
For more details on the methods used, you can always refer to "Beginner's guide to mapping simplexes affinely" and "Workbook on mapping simplexes affinely". The latter contains many problems similar to this one as explained by the authors of the method presented.
