464 Chapter 8 Collision Detection
Capsule and Box
The natural choice for pseudodistance between a box and a capsule is to compute the
distance from the capsule segment to the box and subtract the radius. This quantity
is positive when the objects are separated, zero if they are just touching, and negative
when they are overlapping. The pseudocode is
float Pseudodistance (Capsule capsule, Box box)
{
float sd = SquaredDistance(capsule.segment,box);
return sd/(capsule.r*capsule.r) - 1;
}
The segment-box, squared-distance function is discussed in Section 14.9.3.
Sphere and Triangle
The natural choice for pseudodistance between a sphere and a triangle is to compute
the distance from the sphere center to the triangle and subtract the r adius. This
quantity is ...