Okay I’m working on a Space sim and as most space sims I need to work out where the opponents ship will be (the 3d position) when my bullet reaches it. How do I calculate this from the velocity that bullets travel at and the velocity of the opponents ship?
Share
Calculate the relative velocity vector between him and yourself: this could be considered his movement if you were standing still. Calculate his relative distance vector. Now you know that he is already D away and is moving V each time unit. You have V’ to calculate, and you know it’s length but not it’s direction.
Now you are constructing a triangle with these two constraints, his V and your bullet’s V’. In two dimensions it’d look like:
Dx+Vx*t = V'x*tDy+Vy*t = V'y*tV'x^2 + V'y^2 = C^2Which simplifies to:
(Dx/t+Vx)^2 + (Dy/t+Vx)^2 = C^2And you can use the quadratic formula to solve that. You can apply this technique in three dimensions similarly. There are other ways to solve this, but this is just simple algebra instead of vector calculus.