Consider a plane $\mathbb{R}^2$ and an affine transformation $T: \mathbb{R}^2\to \mathbb{R}^2$ that maps points $A,B,C$ to points $A',B',C'$ correspondingly. We know that $A,B,C$ are not on the same straight line and so $T$ is determined uniquely. Given an arbitrary point $M$ how to find $T(M)$?
Basically, I'm trying to write a program that takes as input 14 numbers—the coordinates of the points $A,B,C, A',B',C',M$ and outputs two numbers—the coordinates of $M'=T(M)$, provided $A,B,C$ are not on the same straight line. How should I proceed?
A general affine map in the plane will be of the form $$T(x,y) = (ax+by+c,dx+ey+f)$$ From the three point-image pairs you can construct the system of equations $$A_1' = aA_1+bA_2 + c \\ A_2' = dA_1 + eA_2 + f \\ B_1' = aB_1+bB_2 + c \\ B_2' = dB_1 + eB_2 + f \\ C_1' = aC_1+bC_2 + c \\ C_2' = dC_1 + eC_2 + f$$ This can be written as a matrix equation: $$\begin{bmatrix} A_1 & A_2 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & A_1 & A_2 & 1 \\ B_1 & B_2 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & B_1 & B_2 & 1 \\ C_1 & C_2 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & C_1 & C_2 & 1\end{bmatrix}\begin{bmatrix} a \\ b \\ c \\ d \\ e \\ f\end{bmatrix} = \begin{bmatrix} A_1' \\ A_2' \\ B_1'\\ B_2' \\ C_1' \\ C_2'\end{bmatrix}$$
Solve it to get the constants that describe your affine map.