So I have a following problem to solve.
I have a firing position a.
I know projectile will have scalar velocity v, but I don't know the vector, because..
..I'm aiming at target which it at position b at the time of firing and has a constant known vector velocity of w. I assume it will be constant, that is.
There is one more factor to count in, however. Gravity. The projectile is affected by gravity vector g.
Now how do I solve this?
I noticed the following thing:
after time t, the projectile will be anywhere on the surface of the sphere with its middle in a + gt^2/2 and radius of vt.
that has to be equal with the position of target after time t, which would be b + wt
with sphere equation it would look like this a + gt^2/2 - b - wt = v^2t^2
Now this is a quartic. It is solveable. Its very complex however. Has anyone got any simlper idea of solving this? My current code doesn't even work apropriatly yet, so I'm not even sure I got this right.
I'll break down my solution. I solve the following for every coordinate.
First, i get my quartic right. Anyone can do this on his own. I have a plain quartic. Now I get the depressed quartic as described at http://en.wikipedia.org/wiki/Quartic_function.
So then I try to get two quadratics from it, as described in said article. I then solve a cubic for a p^2 and get a solution. I take a single solution, which comes from real root of unity and I get my two quadratics. They give me up to 4 real solutions. After appropriate conversion they should give me good results. I am not certain they do. When I have the minimum time of collision, aiming is trivial. Just aim at b + wt - gt^2/2