414 Chapter 8 Collision Detection
bool TestIntersection (ConvexPolygon C0, Vector V0,
ConvexPolygon C1, Vector V1, double tmax, double& tfirst,
double& tlast)
{
// Process as if C0 is stationary, C1 is moving.
V=V1-V0;
tfirst = 0;
tlast = INFINITY;
// Test edges of C0 for separation.
for (i0 = C0.GetN() - 1, i1 = 0; i1 < C0.GetN(); i0 = i1++)
{
D = C0.GetNormal(i0);
ComputeInterval(C0,D,min0,max0);
ComputeInterval(C1,D,min1,max1);
speed = Dot(D,V);
if (NoIntersect(tmax,speed,min0,max0,min1,max1,
tfirst,tlast))
{
return false;
}
}
// Test edges of C1 for separation.
for (i0 = C1.N - 1, i1 = 0; i1 < C1.N; i0 = i1++)
{
D = C1.GetNormal(i0);
ComputeInterval(C0,D,min0,max0);
ComputeInterval(C1,D,min1,max1);
speed = Dot(D,V);
if (NoIntersect(tmax,speed,min0,max0,min1,max1, ...