Game Development Reference

In-Depth Information

7.1.2

T
HE
C
OEFFICIENT OF
R
ESTITUTION

As we saw in the last chapter, when two objects collide, they compress together, and

the springlike deformation of their surfaces causes forces to build up that bring the

objectsapart.Thisallhappensinaveryshortspaceoftime(toofastforustosimulate

frame by frame, although long enough to be captured on very high-speed film). Even-

tually the two objects will no longer have any closing velocity. Although this behavior

is springlike, in reality there is more going on.

All kinds of things can be happening during this compression, and the peculiari-

ties of the materials involved can cause very complicated interactions to take place. In

reality the behavior does not conform to that of a damped spring, and we can't hope

to capture the subtleties of the real process.

In particular the spring model assumes that momentum is conserved during the

collision:

p
a
+

p
b

m
a
˙

p
a
+

m
b
˙

p
b
=

m
a
˙

m
b
˙

[7.3]

where
m
a
is the mass of object
a
,

p
a
is the velocity of object
a
before the collision, and

˙

p
a
is the velocity after the collision.

Fortunately the vast majority of collisions behave almost like the springlike ideal.

We can produce perfectly believable behavior by assuming the conservation of mo-

mentum, and we will use equation 7.3 to model our collisions.

Equation 7.3 tells us about the total velocity before and after the collision, but it

doesn't tell us about the individual velocities of each object. The individual velocities

are linked together using the closing velocity, according to the equation

˙

v
s
=−

cv
s

where
v
s
is the separating velocity after the collision,
v
s
is the separating velocity be-

fore the collision, and
c
is a constant called the “coefficient of restitution.”

The coefficient of restitution controls the speed at which the objects will separate

after colliding. It depends on the materials in collision. Different pairs of material

will have different coefficients. Some objects such as billiard balls or a tennis ball on a

racket bounce apart. Other objects stick together when they collide—a snowball and

someone's face.

If the coefficient is 1, then the objects will bounce apart with the same speed

as when they were closing. If the coefficient is 0, then the objects will coalesce and

travel together (i.e., their separating velocity will be 0). Regardless of the coefficient

of restitution, equation 7.3 will still hold: the total momentum will be the same.

Using the two equations, we can get values for

p
a
and

p
b
.

˙

˙

7.1.3

T
HE
C
OLLISION
D
IRECTION AND THE
C
ONTACT
N
ORMAL

So far we've talked in terms of collisions between two objects. Often we also want to

be able to support collisions between an object and something we're not physically