Let's have a close look at the collision:
When the collision occurs, the velocity vector is splitted; a part is transmitted to the other body while the rest is keeped. In the above illustration, the velocity ( \(\vec{u_1}\)) of body 1 is splited:
The part transmitted is the projection along the axis passing through the center of bodies. Based on the above illustration we can write:
$$ \|\vec{u_{12}}\|=\|\vec{u_1}\|.cos(\gamma) $$
As \(\gamma=\beta-\alpha\), the previous relationship becomes:
$$ \|\vec{u_{12}}\|=\|\vec{u_1}\|.cos(\beta-\alpha) $$
with \(\alpha\) and \(\beta\) given by:
$$ \begin{array}{r c l} \alpha &=& atan2(y_2-y_1,x_2-x_1) \\ \beta &=& atan2(y_{u_1},x_{u_1}) \end{array} $$
In conclusion:
$$ \begin{array}{r c l} \gamma_1 &=& atan2(y_{u_1},x_{u_1}) - atan2(y_2-y_1,x_2-x_1) \\ \|\vec{u_{12}}| &=& \|\vec{u_1}\|.cos(\gamma_1) \\ \|\vec{u_{11}}| &=& \|\vec{u_1}\|.sin(\gamma_1) \\ \gamma_2 &=& atan2(y_{u_2},x_{u_2}) - atan2(y_1-y_2,x_1-x_2) \\ \|\vec{u_{21}}| &=& \|\vec{u_2}\|.cos(\gamma_2) \\ \|\vec{u_{22}}| &=& \|\vec{u_2}\|.sin(\gamma_2) \end{array} $$
and
$$ \begin{array}{r c l}
\alpha_1 &=& atan2(y_2-y_1,x_2-x_1) \\
\vec{u_{12}} &=& \|\vec{u_{12}}\| \left( \begin{array}{r c l} cos(\alpha_1) \\ sin(\alpha_1) \end{array} \right) \\
\vec{u_{11}} &=& \|\vec{u_{11}}\| \left( \begin{array}{r c l} -sin(\alpha_1) \\ cos(\alpha_1) \end{array} \right) \\
\alpha_2 &=& atan2(y_1-y_2,x_1-x_2) \\
\vec{u_{21}} &=& \|\vec{u_{21}}\| \left( \begin{array}{r c l} cos(\alpha_2) \\ sin(\alpha_2) \end{array} \right) \\
\vec{u_{22}} &=& \|\vec{u_{22}}\| \left( \begin{array}{r c l} -sin(\alpha_2) \\ cos(\alpha_2) \end{array} \right)
\end{array}
$$