Scorched Earth
Time for something really exciting... the mother of all games... Scorched Earth!
Haven't heard of it? Well, it's a tanks game from the 90s, and it may well have been the mother of all games back when it was written. Importantly, you can input your angle and launch velocity with numerical values... which means of course that if you have a ruler and calculator on you that you can feel very smart by calculating an exact trajectory. Well, in theory.
In reality, the fact that most of the time you are trying to fire over a hill gets a little in the way. But consider the easiest shot: on a cliff side, overlooking your enemy. When I play I like to input my title as "A2P" for Aspire2Physics, and the CPU as "victim". Anyway, this kind of shot can be fired horizontally: calculate the length of time is takes for the shot to fall to Earth under gravity (S=ut+1/2at2) , and the constant horizontal velocity needed to reach your opponent in this time. This works because rectilinear velocities (ones that are at right angles, such as our horizontal and vertical ones discussed just now) are independant of each other. A good demonstration is that a bullet fired from a gun and one dropped from your hand will land at exactly the same time. A more distressing example is called the Monkey Theorem (google it).
Anyway, that's the easiest shot. What about a more difficult one: how does the CPU return fire? Since nothing is in the way, it can make sure to hit me at it's peak height: when it's vertical velocity is zero, it needs to be at my elevation. You can use V2=U2+2as for this. Since you now have your vertical velocity, you can work out time and hence horizontal velocity exacly as before. Then you'll need to add them together of course. Which requires *shudder* drawing a vector diagram!
Unfortunately, since we're only doing one side of a curve here, we don't have the capability to fire over a mountain. We need something more flexible, and this is where the big guns come in handy. The trajectory of the projectile is it's height as a function of it's horizontal displacement. In other words, we need to find the function y(x).
I'm going to save you some bother and simply write down the equation, but you can probably sort out how to arrive at it if you think for a while. The trajectory is given by:
y(x)=tan(theta)x - gx^2/[2v^2cos^2(theta)]
This is exciting! What we have just written is a quadratic equation, and we know how to solve these! Unfortunately, we don't actually need to "solve" this: we need to find an equation that will intecept us and our target. To make things simpler, we'll place ourselves at the origin, and our victim at the point (x,y). You can't find the equation for a quadratic with only two points, so we also need to know an intermediate point (a,b). This can be any point you want (except the origin or (x,y), of course!) and the obvious choice is the vertex, or maximum point.
Let's quickly rename some of our variables: a general quadratic passing through the origin has the equation:
From our previous example, it seems clear that if we know alpha and beta, we can find our angle and launch velocity. We also have some points, so let's plug them in and solve simultaneously:
a2(alpha)+a(beta)=b
x2(alpha)+x(beta)=y
The above is a fany way or rewriting the previous two lines. This is a 2X2 matrix, and the left hand side can be evaluated by multiplying out the right hand side. You could do this symbolically, and obtain equations for alpha and beta (and if you wanted to, even solve them for velocity and angle!) but you can also store this formula somewhere, then insert values in and multiply using matrix multiplication rules. This is a little bit mathsy, though, so I shan't do it here.
The point is this: Scorched Earth is fun, but the mechanics behind it can be quite deep. Even though it uses very simple mechanics, such as you learn at As and A2 level physics, the solution method can end up quite complicated. And actually, because you often have to fire at very high angles (think 85 degrees from horizontal), and you can only input integer values... this method will stil fail quite often. Sometimes spectacularly. So the game is not ruined (this is still quite difficult BTW, as you need to range-find to work out your screen's scale, then accurately measure your opponents displacement vector from yourself) and anyway, simply turning on air resistance will make all these equations fall flat on their faces. But we have modelled a simple situation accurately enough to beat a game, and that means we have done physics.