How do I aim a constant speed projectile to hit a target if there is a constant acceleration vector acting on it? (For example, the wind and gravity from Worms.)
2 Answers
Let be the position of the target relative to us, and let
be our (the projectile's) velocity relative to the target. The speed
of the projectile and the acceleration vector
are constant. We set up the usual equation of motion:
This is now simply a biquadratic equation, which we can solve for with the usual quadratic formula, and take the square root again to get
:
The lesser and greater positive real roots are the minimum (shallowest) and maximum (steepest) flight times of the projectile, respectively. Both of these will exist if there is any solution. We can then just plug them back into to recover the actual velocity vector. We're normally looking for the minimum flight time solution, but if e.g. there's a hill in the way, the maximum time solution might be able to shoot over it.
-
2\$\begingroup\$ Also relevant: playtechs.blogspot.com/2007/04/aiming-at-moving-target.html \$\endgroup\$– ElectroJun 18, 2013 at 8:34
If you are only interested in calculating a launch angle assuming you have a turret that rotates through an azimuth in the horizontal plane and elevates its barrel at angle theta, there is another equation you can use. Assume you have a coordinate system where x points North, y points vertically, and z points East. Assume the turret is at the origin and the target is at (x0,y0,z0). The target is stationary and the projectile speed is v. The angle is calculated using the equation below:
where C = x02 + z02 and D = g(x02 + z02)/(2v2)