0
$\begingroup$

This problem appeared in a coding project im in the middle of and its driving me crazy. The problem is as follows:

Assume there are two circles $c_1$ and $c_2$, with known position vectors $p_1$, $p_2$ known radii $r_1$, $r_2$ and known velocity vectors $v_1$, $v_2$. The velocities and radii do not change. Also assume that these circles are on a collision course. In "frame 1" We know the position, velocity and radii of both circles before collision and in "frame 2" we know the new positions, velocity and radii of both circles after collision. That is, after both circles have clipped into each each other.

Given this information, what is the position of $c_1$ and $c_2$ at the moment the two circles make contact?

In other words, in "frame 1", $\text{dist}(c_1,c_2)>r_1+r_2$ and in "frame 2" $\text{dist}(c_1,c_2)<r_1+r_2$. What are the positions of $c_1$ and $c_2$ such that $\text{dist}(c_1,c_2)=r_1+r_2$?

I have tried using techniques such as parametric equations, related rates problems and good ol vector calculus to try and find a closed form solution but I keep getting stuck. Its frustrating since I feel like all the information I need is right there but I cant quite figure it out. Im uncertain if there is an analytical solution.

$\endgroup$
4
  • $\begingroup$ If the velocities are given as vectors, then one frame is obviously enough to calculate the point and time of contact. So I assume we only know the absolute value of the velocities, is this correct? $\endgroup$ Commented Jun 5, 2023 at 21:53
  • $\begingroup$ No, We know the whole vector. I guess my mind is blanking about how to calculate point and time of contact. How can I go about that? $\endgroup$ Commented Jun 5, 2023 at 21:58
  • 1
    $\begingroup$ Hint: You have $x_1=p_1+v_1t$ and $x_2=p_2+v_2t.$ Try to solve $\|x_1-x_2\|_2=r_1+r_2$ for $t$ $\endgroup$ Commented Jun 5, 2023 at 22:04
  • $\begingroup$ This makes sense. Lot of dumb algebra but I got something that matches Reinhards answer. Thanks! $\endgroup$ Commented Jun 7, 2023 at 0:36

1 Answer 1

0
$\begingroup$

$x_i(t) = p_i+v_it,$ $i\in\{1,2\},$ is the position of the center of $c_i$ at time $t.$ We are looking for the smallest value $t$ for which $\|x_1(t)-x_2(t)\|_2=r_1+r_2$ holds. We have $\|x_1(t)-x_2(t)\|_2 = \|p_1-p_2 + (v_1-v_2)\,t\,\|_2=r_1+r_2.$

Squaring both sides: $$ \|v_1-v_2\|^2_2\,\,t^2+2\left\langle v_1-v_2, p_1-p_2\right\rangle t +\|p_1-p_2\|^2_2 = (r_1+r_2)^2 $$ or $$ \|v_1-v_2\|^2_2\,\,t^2+2\left\langle v_1-v_2, p_1-p_2\right\rangle t +\|p_1-p_2\|^2_2 - (r_1+r_2)^2 = 0 $$ This is an ordinary quadratic equation which can be solved with the quadratic formula. $$ t = \frac{-\left\langle v_1-v_2, p_1-p_2\right\rangle \pm\sqrt{\left\langle v_1-v_2, p_1-p_2\right\rangle^2 -\|v_1-v_2\|^2_2\left(\|p_1-p_2\|^2_2 - (r_1+r_2)^2\right)}} {\|v_1-v_2\|^2_2} $$ As we know that the circles are going to collide, we will get two positive real values for $t,$ the smaller of which is the time of the first contact, while the larger one is the time when the circles leave each other after having passed through each other.

Now that we know the time $t_0$ of the collision, we also know the locations of the centers of the circles at that time: $x_i(t_0) = p_i+v_it_0,$ $i\in\{1,2\}.$

In order to get the point of contact $x_c$ on the circumferences of the circles, we have to go $r_1$ "steps" from $x_1(t_0)$ towards $x_2(t_0).$ Therefore $$ x_c = x_1 + r_1\frac{x_2-x_1}{\|x_2-x_1\|} = x_1 + r_1\frac{x_2-x_1}{r_1+r_2} = \frac{r_1x_2+r_2x_1}{r_1+r_2} $$

$\endgroup$
3
  • $\begingroup$ Just because im new to this, I have a couple stupid questions. How come squaring both sides gives us an equation with, what I assume, are inner products? $\endgroup$ Commented Jun 6, 2023 at 2:09
  • $\begingroup$ Just expand $\left\|\binom{x_1}{y_1}+\binom{x_2}{y_2}\right\|_2^2.$ After some reordering, you will get $(x_1+x_2)^2+(y_1+y_2)^2 = $ $x_1^2+y_1^2 + 2x_1x_2 + 2y_1y_2 + x_2^2 +y_2^2$ which is $\left\|\binom{x_1}{y_1}\right\|_2^2 + 2\left\langle\binom{x_1}{y_1},\binom{x_2}{y_2}\right\rangle + \left\|\binom{x_2}{y_2}\right\|_2^2.$ $\endgroup$ Commented Jun 6, 2023 at 7:58
  • $\begingroup$ Perfect, that makes so much sense! Thank you! $\endgroup$ Commented Jun 7, 2023 at 0:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .