Friday, 30 December 2011

Angle-free rotation

In my last post I showed how to aim a gun at a target above or below the gun to fire a ballistic missile, i.e. one moving under gravity. The mathematics was entirely angle and trigonometry free, but I noted that the angle can be calculated, in case it's need to e.g. rotate a gun turret. But it's not actually needed for that: it's possible to generate the rotation matrix to line up an object with a direction, without using angles.

Thursday, 29 December 2011

Shooting up and down

In my last post I suggested that avoiding angles and using algebra made it easier to solve the more general ballistics problem of aiming at a target that's higher or lower. It does, and here's how it does it.

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.

Tuesday, 27 December 2011

On Optimisation

This is not about any one optimisation approach but about my overall strategy. It might answer some questions readers have, or at least address concerns I've seen raised elsewhere.

Monday, 26 December 2011

Ballistics update

I created a new version of my ballistics demo. The launcher is now fixed in the bottom-middle of the display and drawn so it's clearer where it's firing from. It fires both angles at once, at the same time and speed, so it's easier to see the difference in flight times and shapes, while it also fires on either side. It is embedded below.


Many games need to calculate the direction, or bearing, between game objects. For example the direction of the player or other game character from a weapon, so the game knows  where to aim the weapon.

The natural way to do this is using angles: when describing the direction of something we commonly use an angular measure, often a crude one such as "North West" or "Two O'clock", distinguishing between eight, twelve or more directions. For more precision degrees can be used, which as numbers can have arbitrary precision.

But often angles are a poor way to measure direction. In particular in games it is rarely best to use angles, for two reasons.