i
i
i
i
i
i
i
i
784 16. Intersection Test Methods
to cope with this problem. This section provides an introduction to the
topic. More information can be found in Ericson’s [315] and Eberly’s [294]
books.
Methods such as shaft culling (Section 16.15) can be used to aid in
intersection testing of moving AABBs. The object moving through space
is represented by two AABBs at different times, and these two AABBs are
joined by a shaft. However, intersection algorithms usually become simpler
and faster if the moving object is contained in a bounding sphere. In fact,
it is often worthwhile to use a set of a few spheres to tightly bound and
represent the moving object [1137].
One principle that can be applied to dynamic intersection testing sit-
uations where only translations (not rotations) take place is the fact that
motion is relative. Assume object A moves with velocity v
A
and object B
with velocity v
B
, where the velocity is the amount an object has moved
during the frame. To simplify calculations, we instead assume that A is
moving and B is still. To compensate for B’s velocity, A’s velocity is then:
v = v
A
−v
B
. As such, only one object is given a velocity in the algorithms
that follow.
16.18.1 Sphere/Plane
Testing a sphere dynamically against a plane is simple. Assume the sphere
has its center at c and a radius r. In contrast to the static test, the sphere
also has a velocity v during the entire frame time Δt.So,inthenextframe,
the sphere will be located at e = c +Δtv. For simplicity, assume Δt is
1 and that this frame starts at time 0. The question is: Has the sphere
collided with a plane π : n · x + d = 0 during this time?
The signed distance, s
c
, from the sphere’s center to the plane is ob-
tained by plugging the sphere center into the plane equation. Subtracting
the sphere radius from this distance gives how far (along the plane normal)
the sphere can move before reaching the plane. This is illustrated in Fig-
ure 16.28. A similar distance, s
e
, is computed for the endpoint e.Now,if
the sphere centers are on the same side of the plane (tested as s
c
s
e
> 0),
and if |s
c
| >rand |s
e
| >r, then an intersection cannot occur, and the
sphere can safely be moved to e. Otherwise, the sphere position and the
exact time when the intersection occurs is obtained as follows [420]. The
time when the sphere first touches the plane is t,wheret is computed as
t =
s
c
− r
s
c
− s
e
. (16.61)
The sphere center is then located at c + tv. A simple collision response
at this point would be to reflect the velocity vector v around the plane
normal, and move the sphere using this vector: (1 − t)r,where1−t is the