You can write any affine transformation
$$
\vec{x}'=A\vec{x}+\vec{t}\;,
$$
where $A$ is any non-singular matrix, as follows:
$$
\left(
\begin{array}{c}
\vec{x}'\\
1
\end{array}
\right)
=
\left(
\begin{array}{cc}
A&\vec{t}\\
0&1
\end{array}
\right)
\left(
\begin{array}{c}
\vec{x}\\
1
\end{array}
\right)
\;.
$$
This allows you to compose affine transformations by composing the corresponding matrices. In this approach, rotations, translations and axis scalings can respectively be written like this:
$$
\left(
\begin{array}{cc}
\Omega&0\\
0&1
\end{array}
\right)
\;,
$$
$$
\left(
\begin{array}{cc}
I&\vec{t}\\
0&1
\end{array}
\right)
\;,
$$
$$
\left(
\begin{array}{cc}
S&0\\
0&1
\end{array}
\right)
\;,
$$
where $\Omega$ is a rotation matrix, $I$ is the identity matrix and $S$ is a diagonal matrix with the scaling factors on the diagonal.
Given any affine transformation specified by $A$ and $\vec{t}$, you can split it into a translation and a linear part:
$$
\left(
\begin{array}{cc}
A&\vec{t}\\
0&1
\end{array}
\right)
=
\left(
\begin{array}{cc}
I&\vec{t}\\
0&1
\end{array}
\right)
\left(
\begin{array}{cc}
A&0\\
0&1
\end{array}
\right)
\;.
$$
So now we just need to be able to write any non-singular matrix as a product of rotations and axis scalings. This is possible due to the singular value decomposition.
You can't represent such a transform by a $2 \times 2$ matrix, since such a matrix represents a linear mapping of the two-dimensional plane (or an affine mapping of the one-dimensional line), and will thus always map $(0,0)$ to $(0,0)$.
So you'll need to use a $3 \times 3$ matrix, since you need to represent affine mappings. If you represent the point $[x,y]$ as the vector $(x,y,1)^T$, then the matrix $$
T_{u,v} = \begin{pmatrix}
1 & 0 & u \\
0 & 1 & v \\
0 & 0 & 1
\end{pmatrix}
$$
represents the translation in the direction $[u,v]$, i.e. $$
T_{u,v} [x,y] = T_{u,v}(x,y,1)^T = (x+u,y+v,1) = [x+u,y+v] \text{.}
$$
To find the representation of a linear mapping as a $3 \times 3$ matrix, simply take the $2\times 2$ matrix that represents the mapping in euclidean two-dimensional space, and embedd it into a $3 \times 3$ matrix like this $$
\begin{pmatrix}
M & 0 \\
0 & 1
\end{pmatrix} \text{.}
$$
For example, you'd represent a rotation around the origin (which is a linear mapping) as $$
R_\varphi = \begin{pmatrix}
\cos\varphi & -\sin\varphi & 0 \\
\sin\varphi & \cos\varphi & 0 \\
0 & 0 & 1
\end{pmatrix} \text{.}
$$
You can use normal matrix multiplication to combine the matrix representation of affice mappings - for example, to rotate around the point $[u,v]$, compute the product matrix $$
T_{u,v} R_\varphi T_{-u,-v} \text{,}
$$
which simply says "shift the center of the rotation to the origin, rotate around the origin and shift back".
Best Answer
Since $p_1, p_2$ and $p_3$ are colinear, we can write $\vec{v} = p_2 - p_3$ and $p2 - p_1 = \lambda \vec{v}$ whence $$ \frac{||p_2-p_1||}{||p_2-p_3||} = \lambda $$ Now write the components of $v$ as $(v_x, v_y)$; we have $$ ||p_2-p_3|| = (v_x, v_y) \\ ||p_2-p_1|| = (\lambda v_x, \lambda v_y) $$
Now apply (multiply by) a scaling transformation. Although it is adequate to just use your example, it might be illuminating to use a general matrix $$S = \pmatrix{a & b \\ c & d}$$with $ad-bc = 1$. $$ S (p_2-p_3)= \pmatrix{ a \,v_x + b \,v_y \\ c \,v_x + d \,v_y}\\ S (p_2-p_1) = \pmatrix{ a \lambda \,v_x + b \lambda\,v_y \\ c \lambda\,v_x + d \lambda \,v_y} = \lambda S(p2-p3)\\ $$