I am quoting from this wiki page
The bolded variables in the following equation are two-dimensional vectors. These are: the position and velocity of particle 1 before collision: $\mathbf{x_1} $ and $\mathbf{v_1}$ and the position and velocity of particle 2 before the collision: $\mathbf{x_2} $ and $\mathbf{v_2}$. In addition the vector $\mathbf{v'_1} $ is the velocity of the first particle immediately after collision while $\mathbf{v'_2}$ is the velocity vector of the second particle immediately after collision.
The equations are:
First define the unit normal vector $\mathbf{n} = \dfrac{\mathbf{x_1} - \mathbf{x_2} }{ \left| \mathbf{x_1} - \mathbf{x_2} \right|}$
$\mathbf{v'_1} = \mathbf{v_1} - \dfrac{2 m_2}{m_1+m_2} (\mathbf{n} \cdot (\mathbf{v_1}-\mathbf{v_2}) ) \mathbf{n} $
and
$\mathbf{v'_2} = \mathbf{v_2} - \dfrac{2 m_1}{m_1+m_2} (\mathbf{n} \cdot (\mathbf{v_2}-\mathbf{v_1}) ) \mathbf{n} $
If we assume that $m_1 = m_2$ (equal masses) then the equations simplify to:
$\mathbf{v'_1} = \mathbf{v_1} - (\mathbf{n} \cdot (\mathbf{v_1}-\mathbf{v_2}) ) \mathbf{n} $
and
$\mathbf{v'_2} = \mathbf{v_2} - (\mathbf{n} \cdot (\mathbf{v_2}-\mathbf{v_1}) ) \mathbf{n} $
As an example, suppose both circles have the same radius and the same mass, and that the first circle is moving with its center position as function of time given by:
$\mathbf{x_1}(t) = (0, -10) + (1, 2) t $
it follows that
$\mathbf{v_1} = (1, 2)$
and suppose that the center of the second circle is
given by
$\mathbf{x_2} = (-10, 0) + (2, 1) t $
it follows that
$\mathbf{v_2} = (2, 1) $
We want to calculate the value of $t$ at which the two circles will collide. Suppose the radius of each of the circles is $1$. Then we want the distance between the centers to be $2$.
We have
$\begin{equation}
\begin{split}
\left| \mathbf{x_1}(t) - \mathbf{x_2}(t) \right| &= \left|(10, -10) + t ( -1, 1 ) \right |\\
&= \sqrt{ 200 - 40 t + 2 t^2 } = 2
\end{split} \end{equation}$
Its solution is $t = 10 \pm \sqrt{2} $
So we'll select $t = 10 - \sqrt{2} $ (the first time after $t = 0$ )
So, at the collision , we have
$\mathbf{x_1} = (0, -10) + (10 - \sqrt{2}) (1, 2) = (10 -\sqrt{2} , 10 - 2 \sqrt{2} ) $
$\mathbf{x_2} = (-10, 0) + (10 - \sqrt{2}) (2, 1) = (10 - 2 \sqrt{2}, 10 - \sqrt{2} )$
Hence the normal vector $\mathbf{n}$ is given by
$\mathbf{n} = \dfrac{1}{\sqrt{2}} (1, -1) $
Substituting all this into the equations, we obtain,
$\begin{equation}
\begin{split}
\mathbf{v'_1} &= (1, 2) - \dfrac{1}{2}( (1, -1)\cdot(1-2, 2 - 1) ) (1, -1) \\
&= (1, 2) + (1 , -1) = (2, 1) \\
\end{split}
\end{equation}$
Similarly, one can obtain that $\mathbf{v'_2} = (1, 2)$
In your particular example:
if the two circles have centres $(x_1,y_1)$ and $(x_2,y_2)$ then they seem to overlap if both
- $|x_1-x_2|+|y_1-y_2| \le 8$
- $\max(|x_1-x_2|,|y_1-y_2|) \le 6$
or alternatively, using a version of Euclidean distance, a single test
- $(x_1-x_2)^2+(y_1-y_2)^2 \le 40$
since the points $(0,0)$ and $(2,6)$ seem to lead to an overlap, while the points $(0,0)$ and $(4,5)$ do not
Best Answer