[Math] Where to shoot to hit a moving target in 3D space

analytic geometryvectors

Typical problem of many computer games and also reality (targeting computers of modern jets or anti-aircraft systems):

You have a target at known position and it is flying at known constant velocity. You're trying to shoot at it with a projectile, which flies at known constant speed and unknown but constant direction. Now it is needed to calculate the point at which you have to shoot (how much in front of the target), so that both target and projectile meet at the same time at this point.

So what i know:

  • target position T = [x,y,z]
  • target velocity v = (x,y,z)
  • projectile speed s (scalar only)

What i want to get:

  • position of their collision (or vector of the bullet, or time after which they collide … any other value, which is convertible to these)

For simplification, let's forget gravity, air resistance, etc. Let's imagine this is in space far from any influences.

Although this first seemed to me as a trivial problem, i have been unable to come up with a solution even after many hours. Any advices?

Best Answer

At time $0$ target is at position $\vec T_0$ and bullet is fired from the origin with speed $\vec s$. If $t$ is the collision time you have the equation $$ \vec s t = \vec T_0 + \vec v t. $$ Squaring both sides one gets $s^2t^2=T_0^2+v^2t^2+2(\vec T_0\cdot\vec v)t$, that is: $$(s^2-v^2)t^2-2(\vec T_0\cdot\vec v)t-T_0^2=0,$$ an equation which can be solved to obtain $t$. Once $t$ is known you can compute $ \vec s=\vec v +\vec T_0/t. $

Related Question