Wednesday, 28 December 2011

Angle-free ballistics

After my post on Monday an obvious question is whether ballistics can be done without angles. The answer is they can, and there are advantages in doing so. This may seem counter-intuitive as finding the angle is a key problem in ballistics, when firing artillery over distance, and requires significant calculations. But dealing with virtual cannons or ballistas we have far more flexibility and can avoid angles altogether.

The key observation is that the angle is used to calculate the initial horizontal and vertical speed components, vx and vy. But they also form a vector, (vx, vy) with magnitude equal to the speed, so are related by the formula

The condition that the missile hits the ground at range r can be put into the equations of motion to get

And the above formulae can be combined to eliminate vx and vy, forming a quadratic equation for t2, where t is the time of flight, which can then be easily solved to find the two values for t2

These can be used to calculate t, from which the velocity components can be found, avoiding angles and trigonometry altogether, although the angle can still be calculated, perhaps to rotate a gun graphic. This method is not especially faster but is algebraically simpler, so is better for more complex problems such as those where the target is higher or lower than the shooter.

I've done yet another version of the ballistics app using the above mathematics, embedded below. It works the same way as before but uses new calculations as above.