Closest approach of two airplanes with intersecting paths on a 2D plane

76 Views Asked by At

I'm writing a program that has to find the closest approach of two airplanes.

The problem could be brute-forced, but that would be a waste of opportunity to solve it in an elegant way. I was unable to do it even after resarching the problem online - your help is much appreciated.

Assumptions:

  • There are two airplanes in a 2D coordinate plane.
  • Each airplane is defined by its starting position and vector (direction and velocity)

  • Starting positions of airplane #1 and airplane #2 are defined by random, non-negative coordinates: $(x_1,y_1)$ and $(x_2,y_2)$ respectively.

  • Airplane #1 has a random direction $(θ_1)$ defined by angle relative to north (or the y axis): $<0;360)$
  • Airplane #2 has a random direction $(θ_2)$ such that it crosses the future path of airplane #1
  • The velocities of airplanes $(ρ_1, ρ_2)$ are random numbers: $<1;2>$.
  • Just to clarify: the velocities will almost always be different numbers - they don't have to be equal.

Find coordinates of airplanes at the moment of closest approach

i.e. at the moment in time when airplanes are closest to each other.

Thank you for your help!

1

There are 1 best solutions below

0
On BEST ANSWER

the vector displacement between the planes is given by ... $$ \vec d =(d_x+v_xt,d_y+v_y t ) $$

where $d_x = x_2-x_1$ , $d_y = y_2-y_1$

$v_x = \rho_2 \sin(\theta_2) - \rho_1 \sin(\theta_1) $

$v_y = \rho_2 \cos(\theta_2) - \rho_1 \cos(\theta_1) $

the magnitude of $\vec d $ is minimized when

$$ t = -\frac{d_x v_x + d_y v_y}{v_x^2 + v_y^2} $$