Game Development Reference
In-Depth Information
Whether it's modeling arrows, cars, boats, or airplanes, every physical model that describes a body
in motion will use the basic kinematic relations.
The chapter began with an examination of translational motion. If the forces acting upon
an object can be determined, the acceleration, velocity, and position of the object can be
computed as a function of time. If the net external force is constant, the equations of motion
can sometimes by solved directly into simple algebraic equations. In more complicated cases,
an ODE solver can be used to solve the equations of motion. We developed a general-purpose
fourth-order Runge-Kutta solver in this chapter that can be applied to many different game
programming situations.
The next section of the chapter dealt with rotational motion. The concepts of torque and
moment of inertia were introduced as well as equations that related torque to angular acceler-
ation and velocity. The subject of rigid body motion, the combined translational and rotational
motion of an object, was discussed. We looked at two real-world examples of rigid body anal-
ysis—an object rolling down a ramp and a bowling ball traveling down the lane.
Answers to Exercises
1.
Because velocity and acceleration are vectors that can be divided into directional com-
ponents, the vertical velocity is independent of the horizontal velocity. If the only force
considered is gravitational and the bullet and ball start with the same initial vertical
location and velocity, they will strike the ground at the same time.
2.
Assume that the x-direction is parallel to the ground and the z-direction is vertical. The
soccer ball starts with an initial horizontal velocity of v x = 12cos(45) = 8.49 m/s . Assuming
no changes to the horizontal velocity, the soccer ball will reach the plane of the goal in
t = 5/8.49 = 0.59 s .
The soccer ball will have an initial vertical velocity of v y = 12sin(45) = 8.49 m/s . Assuming
that the only force on the ball is due to gravity, the height of the ball at 0.59 s will be
1
1
(
) (
)
2
2
zt
( )
=−
gt
+
vt
+
z
=−
9.8
0.59
+
8.49 * 0.59
=
3.3
m
o
o
2
2
The ball will sail over the goal, and the crowd will moan “Awwwwww.”
The acceleration due to gravity needs to be added to the expression for dq[0] in the
getRightHandSide method of the SpringODE class. Here is the modified code included
the gravity term.
3.
public double[] getRightHandSide(double s, double q[],
double deltaQ[], double ds, double qScale) {
double dq[] = new double[4]; // right-hand side values
double newQ[] = new double[4]; // intermediate dependent
// variable values.
Search WWH ::




Custom Search