# Change system of coordinates, having initial and final coords, find the way

I have points ( how many we needs) with coordinates $(x_1,y_1)$ , $(x_2,y_2)$ , $(x_3,y_3)$ ... in the cartesian System 1 ( actually, a millimetered sheet ) and the corresponding coordinates $(a_1,b_1)$ , $(a_2,b_2)$ , $(a_3,b_3)$ in another system, System 2, that we can assume cartesian.

E.g. from manual measurement I know points :
A is (334,491) in System 1, and ( 46.604856, 34.833369 ) in System 2
B is ( 1273,209 ) in System 1, and ( 46.609281, 34.835422 ) in System 2
C is ( 1721,1032 ) in System 1, and ( 46.608634, 34.840995 ) in System 2

Surely are involved a rotation, a linear deformation and a translation. I must find them, to calculate the coordinates of an arbitrary but near point ( near to my known points ) in a system, given the coordinates in the other.

I read Change from one cartesian co-ordinate system to another by translation and rotation. getting few hints, my level is far below this problem

A general affine transformation does something like

\begin{align*} a &= px + qy + r \\ b &= sx + ty + u \end{align*}

so with three points and their images, you have $6$ linear equations and can solve for these 6 variables, $p,q,r,s,t,u$. One way would be Gaussian elimination on a $6\times 6$ (sparse) system of linear equations. Another would be writing this as a matrix equation, similar to what I did in this answer:

\begin{align*} \begin{pmatrix} p & q & r \\ s & t & u \\ 0 & 0 & 1 \end{pmatrix}\cdot\begin{pmatrix} x_1 & x_2 & x_3 \\ y_1 & y_2 & y_3 \\ 1 & 1 & 1 \end{pmatrix}&=\begin{pmatrix} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ 1 & 1 & 1 \end{pmatrix} \\ \begin{pmatrix} p & q & r \\ s & t & u \\ 0 & 0 & 1 \end{pmatrix}&=\begin{pmatrix} a_1 & a_2 & a_3 \\ b_1 & b_2 & b_3 \\ 1 & 1 & 1 \end{pmatrix}\cdot\begin{pmatrix} x_1 & x_2 & x_3 \\ y_1 & y_2 & y_3 \\ 1 & 1 & 1 \end{pmatrix}^{-1} \end{align*}

So if you have the formula for the inverse of a $3\times3$ matrix, a bit of matrix multiplication will determine the parameters of the transformation. Bear in mind that if the three lines are collinear, you have insufficient information and will encounter a division by zero.