My friend Justin was reminiscing about some Atari-aged video games: Subspace/Continuum. The problem they inspired reminds me more of Asteroids.

Problem:

A turret in a video game can rotate but not change location. It shoots bullets that travel with a constant velocity *V _{B}*. An asteroid travels at a constant velocity

*V*. Where should the turret aim to hit the asteroid?

_{A}Solution:

You'll never find where you're going if you don't know where you started. Let's put the turret at the center of a Cartesian plane. Add a point

*A*for the asteroid at (

*x*,

_{0}*y*), and add a point for the eventual collision at (

_{0}*x*,

_{1}*y*). Label the distances traveled by the asteroid and the bullet

_{1}*D*and

_{A}*D*. Recall that little ditty: "Distance = Rate × Time." We can use this whenever we are dealing with constant velocities. I've already labeled arrows

_{B}*R*and

_{A}*R*to represent the rates in the diagram.(I'm listing the equation numbers (abbreviated "eqn") on the left. When I use those equations later, I'll show which equation number I used on the right.) Note: the bullet and the asteroid travel for the same amount of time once the bullet is fired, so

_{B}*T*has the same value in each equation.

We have two equations and three unknowns, so we'll need to find some more relationships. I can find more information about

*D*and

_{A}*D*by breaking the distances into their horizontal and vertical components. I've added these components to the diagram below.Let β be the angle that the bullet's trajectory makes with the x-axis, and call the angle that the ship flies at with respect to the x-axis α.With all of these variables in play, let's take a moment to recap what is known and what we need to find.Now, we need to trade our variables down to get rid of some of those unknowns. I'll start with

_{B}*x*. Now do the same with the sines to get rid of

_{1}*y*. Now that we've gotten rid of

_{1}*x*and

_{1}*y*, solve for

_{1}*T*in equation 11 and substitute into equation 15... ...and simplify. Now we're down to one unknown: β. To find β, solve for sin(β), square both sides, and substitute 1 - cos

^{2}(β) for sin

^{2}(β). Then, use the quadratic equation to solve for the possible values of cos(β), and convert those values into the angles we want. Once we have β, we use equation 18 to find

*T*and equations 4 and 5 to find

*x*and

_{1}*y*.

_{1}I'm not going to attempt to finish this solution unless someone asks me to. I'm too likely to make a mistake somewhere in the tangled mass of algebra that is to follow, and Justin has access to math software that can do the manipulations for him. Comment if you have any questions.

## 2 comments:

All of which takes way too long, and you lose the game.

the brain can estimate all that in an instant, just lead the asteroid by what seems to be the correct amount. You'll get the hang of it after a few tries.

[/snark]

What, you can't do those calculations in your head in a fraction of a second?

I think Justin wants to design a game in which the computer will have to aim the turret, so no groovy organic brain to do the estimation.

Post a Comment