For example, I have 4 points with the following global coordinates $(4,2),(5,3),(6,4),(8,5)$. Graph
How to transform these global coordinates into local, such that the first point is $(0,0)$ in the new local coordinate system, and that x axis goes through the second point. Graph 2
You know you want to make a rotation to the axes and then a translation : $$\begin{pmatrix} X\\ Y \end{pmatrix} = \begin{pmatrix} a & -b\\ b & a \end{pmatrix}\begin{pmatrix} x\\ y \end{pmatrix} +\begin{pmatrix} c\\ d \end{pmatrix} $$ Here you have $c=4$ and $d=2$. In order to find $a$ and $b$, you take the normed director vector $u$ from the line which pass through $(4,2)$ and $(5,3)$ and the director vector $v=(1,0)$, and you solve for $a$ and $b$ : $$v=\begin{pmatrix} a & -b\\ b & a \end{pmatrix}u$$