Game Development Reference
In-Depth Information
as the desired multiple of the relative velocity along the normal before
impact.
rel
v
n = −e v rel
n ,
Solving for k, the
magnitude of the impulse
1
( v
v
2 ) n = −e v rel
n ,
[( v 1
− k n /m 1 ) − ( v 2 + k n /m 2 )] n = −e v rel
n ,
[( v 1
v 2 ) − (k n /m 1 + k n /m 2 )] n = −e v rel
n ,
[ v rel
− k(1/m 1 + 1/m 2 ) n ] n = −e v rel
n ,
v rel
n − k(1/m 1 + 1/m 2 ) n n = −e v rel
n ,
k(1/m 1 + 1/m 2 ) n n = (e + 1) v rel
n ,
n
(1/m 1 + 1/m 2 ) n n .
(e + 1) v rel
k =
(12.23)
Equation (12.23) can be simplified slightly in the common case that n is
known to have unit length. If n is not a unit vector, then the change to k
as a result of the length of n is balanced by the calculation of the (vector)
impulse k n . Thus k is the true magnitude of the impulse only when n is a
unit vector.
Let's work through a few examples of Equation (12.23). First, let's
see how the coe cient of restitution can be used to describe the difference
between dropping a beanbag and a SuperBall. We'll be dropping these
objects onto a concrete floor, which is an enlightening example because it
shows how immovable objects can be easily handled in most physics engines
by acting as if they have infinite mass. As it turns out, the inverse mass
is the quantity we usually work with in calculations involving such special
objects (as illustrated in Equation (12.23)). Furthermore, the inverse mass
(and its analog, the inverse inertia tensor, to be discussed later) are derived
quantities that are needed so frequently that they are often precomputed.
This means that physics code can often work with immovable 16 objects
without treating them as a special case, simply by setting the inverse mass
equal to zero. When one of the inverse masses is zero, we could actually
deal directly with velocities and bypass Equation (12.23), since k will be
proportional to the mass but the velocity change as a result of applying k is
inversely proportional to the mass. Later, we solve a general case example
where no such simplifications are possible.
16 Actually, an object don't necessarily have to be stationary to be “special” like this.
Consider a platform that moves along a spline path created by a level designer, or some
other hand-animated object that is not allowed to deviate from its prescribed trajectory.
These so-called kinematically controlled objects do move around in the world and must
be known to the physics engine if other (nonkinematically controlled!) objects need to
interact with them, but such objects do not respond to forces, and their position is not
updated by the physics engine. Although the mass of these objects is treated as infinite,
proper collision response requires knowledge of the (kinematically determined) velocity.
Search WWH ::




Custom Search