Sunday, January 15, 2017

mathematics - How to account for acceleration when aiming projectiles?


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.)



Answer




Let x be the position of the target relative to us, and let v be our (the projectile's) velocity relative to the target. The speed ||v|| of the projectile and the acceleration vector a are constant. We set up the usual equation of motion:


Final equation of derivation: 0 = x.x - (x.a + ||v||^2)*t^2 + a.a * t^4 / 4


This is now simply a biquadratic equation, which we can solve for t^2 with the usual quadratic formula, and take the square root again to get t:


t=sqrt((x.a+||v||^2 +- sqrt((x.a + ||v||^2)^2 - (a.a)(x.x))/((a.a)/2))


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 v=x/t-1/2 * a * t 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.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...