Game Development Reference
In-Depth Information
We'll show you how to set up the kinematic equations for this problem by treating each
vector component separately at first and then combining these components.
X Components
The x components here are similar to those in the previous section's rifle example in
that there is no drag force acting on the shell; thus, the x component of acceleration is
0, which means that the x component of velocity is constant and equal to the x compo‐
nent of the muzzle velocity as the shell leaves the cannon. Note that since the cannon
barrel may not be horizontal, you'll have to compute the x component of the muzzle
velocity, which is a function of the direction in which the cannon is aimed.
The muzzle velocity vector is:
v m = v mx i + v my j + v mz k
and you are given only the direction of v m as determined by the direction in which the
user points the cannon, and its magnitude as determined by the amount of powder the
user packs into the cannon. To calculate the components of the muzzle velocity, you
need to develop some equations for these components in terms of the direction angles
of the cannon and the magnitude of the muzzle velocity.
You can use the direction cosines of a vector to determine the velocity components as
cos θ x = v mx /v m
cos θ y = v my /v m
cox θ z = v mz /v m
Refer to Appendix A for a description and illustration of vector direction cosines.
Since the initial muzzle velocity vector direction is the same as the direction in which
the cannon is aimed, you can treat the cannon as a vector with a magnitude of L , its
length, and pointing in a direction defined by the angles given in this problem. Using
the cannon length, L , and its components instead of muzzle velocity in the equations
for direction cosines gives:
cos θ x = L x /L
cos θ y = L y /L
cos θ z = L z /L
In this example, you are given the angles α and γ (see Figure 2-4 ) that define the cannon
Search Nedrilad ::

Custom Search