Intersection point of two vehicles in 2D, one with $\vec{speed}$, the other with $|speed|$.

101 Views Asked by At

I have a problem where I need to find the point of intersection of two vehicles given their initial positions and velocities. Here's what I have:

Vehicle 1:

  • Departure time: $t=0$
  • Initial position: $\vec {P_1}$
  • Velocity vector: $\vec {V_1}$

At any time $t$, the position of Vehicle1 is given by:

$\vec{P_1}+t\ \vec {V_1}$

Vehicle 2:

  • Departure time: $t= K$ ($K$ any delta of time $\ge 0$)
  • Initial position: $\vec {P_2}$
  • Velocity: $|V_2|$ (components unknown)

At any time $t$, the position of Vehicle 2 is given by:

$\vec {P_2}+(t−K)\ \vec {V_2}$

where $V_2$ is the velocity vector of Vehicle 2 with an unknown direction but a known magnitude.


Example:

enter image description here

Vehicle 1 has trajectory red. Vehicle 2 has trajectory green. The intersection point is (1)

$\vec {P_1} = (-2,1)$
$\vec {P_2} = (2,-4)$
$\vec {V_1} = (5,1)$
$|V_2| = 2\sqrt{37}$
$K = 0.5$

Expected result: $\vec I = (3,2)$


I want to find the point where these two vehicles intersect, considering they will intersect at the same time (if they do).

The arithmetic solution become a huge quartic equation, difficult to manage.

$P_1.x + V_1.x \ t_1 = P_2.x + x \ t_2$

$P_1.y + V_1.y \ t_1= P_2.y + y \ t_2$

$\sqrt{x^2 + y^2} = |V_2|$

$t_2 = t_1-K$

I could also probably solve this with numerical methods, but I would like to explore if there is a algebraic solution which does not explode in complexity.

3

There are 3 best solutions below

0
On BEST ANSWER

You can determine the second vehicle's direction along the way if you're interested in that.

Vehicle 1's position at time $t$:

$$\vec A(t) = \vec P_1 + \vec V_1 t = (p_{1x} + v_{1x}t)\,\vec\imath + (p_{1y}+v_{1y}t) \, \vec\jmath$$

Vehicle 2's position at time $t$:

$$\vec B(t) = \vec P_2 + \vec V_2 (t-K) = \left(p_{2x} + \left\|\vec V_2\right\| \cos\theta \, (t-K)\right) \, \vec\imath + \left(p_{2y} + \left\|\vec V_2\right\| \sin\theta \, (t-K)\right) \, \vec\jmath$$

Solve for $t$; the two vehicles will meet at

$$t = \frac{p_{2x}-p_{1x} - \left\|\vec V_2\right\| K \cos\theta}{v_{1x} - \left\|\vec V_2\right\| \cos\theta} = \frac{p_{2y}-p_{1y} - \left\|\vec V_2\right\| K \sin\theta}{v_{1y} - \left\|\vec V_2\right\| \sin\theta}$$

Now you can solve for $\theta$, then find a general solution for $t$ and the intersection.


Re. your cooked up example, the above formula leads to

$$t = \frac{4 - \sqrt{37} \cos\theta}{5 - 2\sqrt{37} \cos\theta} = - \frac{5 + \sqrt{37}\sin\theta}{1 - 2\sqrt{37} \sin\theta} \\ \implies 11\sqrt{37}\cos\theta + 3\sqrt{37}\sin\theta = 29\\ \implies \theta = 2\arctan\frac{\sqrt{37}-1}6 \approx 80.54^\circ$$

and we can confirm that $t=1$ and the intersection is $(3,2)$ in this case.

0
On

As a sidenote, I tried to find the quartic you referenced and was unable to replicate your method. I have shown a correct method below but am unable to explain where your method went wrong.

To restate your question: You are trying to find $P_1 + tV_1$ under the condition we know $P_1,V_1$, so it will suffice to find $t$.

Starting with the equation $$P_1 + tV_1 = P_2 + (t-K)V_2$$ we first subtract $P_2$ from both sides, $$P_1 - P_2 + tV_1 = (t-K)V_2,$$ and then apply $|\cdot|^2$ to both sides to find $$|P_1 - P_2 + tV_1|^2 = (t-K)^2|V_2|^2.$$

In terms of the variable $t$, both sides of this equation are entirely known. Specifically, given your values, the equation is $$((-2)-2+5t)^2 + (1-(-4)+t)^2 = (t-\tfrac12)^2\cdot (2\sqrt{37})^2$$ This is quadratic in $t$, so while it takes some work to put it in standard form, the method to solve it is routine, $$61t^2-59t-2=0$$ $$(61t+2)(t-1)=0$$ Since $t>K$ by assumption, $t=1$, so the intersection is $$P_1 + 1\cdot V_1 = (-2,1)+(5,1) = (3,2)$$

0
On

So, if this can help someone else:

$t1$ can be resolved with the quadratic equation given following coefficients:

$A_{coeff} = V1_x² + V1_y² - G²$
$B_{coeff} = 2 \cdot P1_x \cdot V1_x + 2 \cdot P1_y \cdot V1_y + 2 \cdot K \cdot | V2 |² - 2 \cdot P2_x \cdot V1_x - 2 \cdot P2_y \cdot V1_y $
$C_{coeff} = P1_x² + P2_x² - 2 \cdot P1_x \cdot P2_x + P1_y² + P2_y² - 2 \cdot P1_y \cdot P2_y - K² \cdot |V2|²$

Supposing the example provided in the question:

$A_{coeff} = -122$
$B_{coeff} = 118$
$C_{coeff} = 4$

Replacing in the standard solution of quadratic equation:

$t1_1, t1_2 = \frac{-118 \pm \sqrt{118^2 - 4(-122)(4)}}{2(-122)}$
$t1_1 = \frac{8}{-244}$
$t1_2 = 1$

Then, t2:

$t2 = t1-K = 0.5$

$\vec V2$ can be solved:

$V2_x = \frac{P1_x - P2_x + t1 \cdot V1x}{t2} $
$V2_y = \frac{P1_y - P2_y + t1 \cdot V1y}{t2} $

$V2_x = \frac{-2 - 2 + 1(5)}{1 - 0.5} = 2$
$V2_y = \frac{1 + 4 + 1(1)}{1 - 0.5} = 12$

And the intersection point:

$\vec I = \vec P1 + \vec V1 \cdot t1$
$\vec I = \vec {(-2, 1)} + \vec {(5,1)} \cdot 1 = \vec {(3,2)}$