I have two mobiles, I know their positions and velocities. I want to be able to determine in how many time they will be the closest if they still move at the same velocity. In a book I read, they present this formula : $t_{closest} = \frac{dp.dv}{||dv||²}$
With :
- Considering all in 2D
- $t_{closest}$ is in how many time they will be the closest possible
- $dp = p_2 - p_1$
- $p_1$ = position of mobile 1 at start
- $p_2$ = position of mobile 2 at start
- $dv = v_2 - v_1$
- $v_1$ = velocity of mobile 1 at start
- $v_2$ = velocity of mobile 2 at start
- ||dv|| is the magnitude of dv
I try it and it works, but I didn't succeed at demonstrating it
Is someone able to explain me how demonstrate this formula?
Thank you,
The position at time $t$ of the two mobiles are resp. $p_1+tv_1$ and $p_2+tv_2$.
Their squared distance is :
$$d(t)=\|(p_2+tv_2)-(p_1+tv_1)\|^2=\|(p_2-p_1)+t(v_2-v_1)\|^2=\|dp+t \ dv\|^2=(dp+t \ dv).(dp+t \ dv)$$
(Squared norm is the same as squared dot product). Expanding :
$$d(t)=t^2\underbrace{\|dv\|^2}_A+t \underbrace{(2 dp.dv)}_{B} +\underbrace{\|dp\|^2}_{C}.$$
$d(t)$ is a quadratic in $t$ with leading coefficient $A>0$.
In such a case, it is well known that it has a minimum occuring for
$$t=-\dfrac{B}{2A}=\color{red}{-}\dfrac{dp.dv}{\|dv\|^2}$$
as desired (but with a minus sign).
Remark : Subtracting position and speed of mobile n° 2 to mobile n°1, is equivalent to estimate a relative position, that can be explained as the trajectory of mobile n°2 as seen on the radar of mobile n°1.