Game Development Reference
In-Depth Information
Exercise
1. A solid sphere with a mass of 1 kg and with velocity components v 1 x = 20 m/s and v 1 y = 4 m/s strikes
a second sphere with a mass of 9 kg and velocity components of v 2 x = 5 m/s and v 2y = -3 m/s .
Assuming that the line of action for the impact is parallel to the x-axis and that the coefficient of resti-
tution is 0.9, determine the post-collision velocity components.
Collisions with Immovable Objects
In the previous section, equations were derived to compute the post-collision velocities of two
objects. How would the equations be applied to the situation where one of the objects is
immovable? This situation would occur frequently in game programming applications—a
baseball could hit a foul pole or a golf ball could hit a tree, for example. Equation (6.14a) can be
used to determine the velocity of an object after it collides with an immovable object if two
assumptions are made. The first assumption is obvious—the velocity of the second object is
assumed to be zero. The second assumption that is made is that the mass of the second object
is infinite, so that the impulse applied to the immovable object does not change its (zero)
momentum. Under these assumptions, Equation (6.14a) takes a very simple form.
=−
v
ev
(6.15)
1
x
1
x
We can see from Equation (6.15) that when an object strikes an immovable object, it bounces
off the immovable object in the opposite direction to its initial motion. The post-collision
velocity is determined by the coefficient of restitution. If e = 0, the post-collision velocity of the
moving object is zero (the moving object would stick to the immovable object). If e = 1, the pre-
and post-collision velocities have the same magnitude but the opposite directions.
Exercise
2. An object with a mass of 1 kg is dropped from a height of 2 meters. If the object strikes a concrete slab
and the coefficient of restitution for the collision is 0.9, determine the height to which the object will bounce.
Linear Collision Simulator
Let's write a simple linear collision simulator that will demonstrate some of the factors that
affect linear collisions. The class that implements the simulator is called SphereCollision , and
a sample screen shot of the simulator is shown in Figure 6-5. The simulator consists of two
spheres that move in the horizontal direction. The mass and initial velocities of the spheres are
defined by the values inside text fields. Another text field allows the user to change the coeffi-
cient of restitution between the spheres. A Start button starts the spheres moving and a Reset
button stops the simulation and resets the spheres to their original positions.
Search WWH ::




Custom Search