Game Development Reference

In-Depth Information

Figure 2-4. Cannon orientation

Using these angles, it follows that the projection,
b
, of the cannon length,
L
, onto the x-

z plane is:

b = L cos(90° - α)

and the components of the cannon length,
L
, on each coordinate axis are:

Lx = b cos γ

Ly = L cos α

Lz = b sin γ

Now that you have the information required to compute direction cosines, you can write

equations for the initial muzzle velocity components as follows:

v
mx
= v
m
cos θ
x

v
my
= v
m
cos θ
y

v
mz
= v
m
cos θ
z

Finally, you can write the
x
components of displacement, velocity, and acceleration as

follows:

a
x
= 0

v
x
= v
mx
= v
m
cos θ
x

x = v
x
t = (v
m
cos θ
x
) t

Y Components

The
y
components are just like the previous rifle example, again with the exception here

of the initial velocity in the y-direction: