236 Chapter 6 Distance in 2D
The GJK algorithm is effectively a descent method that constructs a sequence of
points on the boundary of C, each point having smaller distance to the origin than
the previous point in the sequence. In fact, the algorithm generates a sequence of
simplices with vertices in C (triangles in 2D, tetrahedra in 3D), each simplex having
smaller distance to the origin than the previous simplex. Let S
k
denote the simplex
vertices at the kth step, and let
¯
S
k
denote the simplex itself. The point V
k
∈
¯
S
k
is
selected to be the closest point in
¯
S
k
to the origin. Initially, S
0
=∅(the empty set)
and V
0
is an arbitrary point in C. The set C is projected onto the line through 0 with
direction V
0
, the resulting projection being a closed and bounded interval on the line.
The interval end point that is farthest left on the projection line is generated by a point
W
0
∈C. The next set of simplex vertices is S
1
={W
0
}. Figure 6.25 illustrates this step.
Since S
1
is a singleton point set,
¯
S
1
= S
1
and V
1
= W
0
is the closest point in
¯
S
1
to the origin. The set C is now projected onto the line containing 0 with direction
V
1
. The interval end point that is farthest left on the projection line is generated by a
point W
1
∈C. The next set of simplex vertices is S
2
={W
0
, W
1
}. Figure 6.26 illustrates
this step.
The set
¯
S
2
is the line segment W
0
, W
1
. The closest point in
¯
S
2
to the origin is
an edge-interior point V
2
. The set C is projected onto the line containing 0 with
direction V
2
. The interval end point that is farthest left on the projection line is
generatedbyapointW
2
∈ C. The next set of simplex vertices is S
3
={W
0
, W
1
, W
2
}.
Figure 6.27 illustrates this step.
The set
¯
S
3
is the triangle W
0
, W
1
, W
2
. The closest point in
¯
S
3
to the origin is
a point V
3
on the edge W
0
, W
2
. The next simplex vertex that is generated is W
3
.
The next set of simplex vertices is S
4
=W
0
, W
2
, W
3
. The old simplex vertex W
1
is
discarded. Figure 6.28 illustrates this step. The simplex
¯
S
3
is shown in dark gray.
Generally, V
k+1
is chosen to be the closest point to the origin in the convex hull
of S
k
∪{W
k
}. The next set of simplex vertices S
k+1
is chosen to be set M ⊆ S
k
∪{W
k
}
with the fewest number of elements such that V
k+1
is in the convex hull of M. Such
asetM must exist and is unique. Figure 6.29(a) shows the convex hull of S
3
∪{W
3
},
a quadrilateral. The next iterate V
4
is shown on that hull. Figure 6.29(b) shows the
simplex
¯
S
4
that was generated by M ={W
0
, W
2
, W
3
}.
We state without proof that the sequence of iterates is monotonically decreasing
in length, V
k+1
≤V
k
. In fact, equality can only occur if V
k
=Z, the closest point.
For convex faceted objects, the closest point is reached in a finite number of steps. For
general convex objects, the sequence can be infinite, but must converge to Z.Ifthe
GJK algorithm is implemented for such objects, some type of termination criterion
must be used. Numerical issues also arise when the algorithm is implemented in a
floating-point number system. A discussion of the pitfalls is given by van den Bergen
(1997, 1999, 2001a), and the ideas are implemented in a 3D collision detection
system called SOLID (Software Library for Interference Detection) (van den Bergen
2001b). The main concern is that the simplices eventually become flat in one or more
dimensions.