$$ \begin{array}{r c l} \alpha_1 &=& atan2(y_2-y_1,x_2-x_1) \\ \beta_1 &=& atan2(y_{u_1},x_{u_1}) \\ \gamma_1 &=&\beta_1-\alpha_1 \\ \alpha_2 &=& atan2(y_1-y_2,x_1-x_2) \\ \beta_2 &=& atan2(y_{u_2},x_{u_2}) \\ \gamma_2 &=&\beta_2-\alpha_2 \end{array} $$
$$ \begin{array}{r c l} \|\vec{u_{12}}\| &=& \|\vec{u_1}\|.cos(\gamma_1) \\ \|\vec{u_{11}}\| &=& \|\vec{u_1}\|.sin(\gamma_1) \\ \|\vec{u_{21}}\| &=& \|\vec{u_2}\|.cos(\gamma_2) \\ \|\vec{u_{22}}\| &=& \|\vec{u_2}\|.sin(\gamma_2) \end{array} $$
$$ \begin{cases}
\|\vec{v_{12}}\| = \frac{ (m_1-m_2)\|\vec{u_{12}}\| - 2m_2\|\vec{u_{21}}\| }{m_1+m_2} \\
\|\vec{v_{21}}\| = \frac{ (m_1-m_2)\|\vec{u_{21}}\| + 2m_1\|\vec{u_{12}}\| }{m_1+m_2}
\end{cases}
$$
$$ \vec{v_1}=\|\vec{u_{11}}\| \left( \begin{array}{r c l} -sin(\alpha) \\ cos(\alpha) \end{array} \right) + \|\vec{v_{12}}\| \left( \begin{array}{r c l} cos(\alpha) \\ sin(\alpha) \end{array} \right) $$
$$ \vec{v_2}=\|\vec{u_{22}}\| \left( \begin{array}{r c l} -sin(\alpha_2) \\ cos(\alpha_2) \end{array} \right) - \|\vec{v_{21}}\| \left( \begin{array}{r c l} cos(\alpha_2) \\ sin(\alpha_2) \end{array} \right) $$