6.10 GJK Algorithm 233
If the linear component is a segment, the distance is first calculated between the
line of the segment and the curve. If Y is the closest point on the line to the curve,
then Y = P + t
d for some t.Ift ∈ [0, 1], then Y is already on the segment, and
the distance from the segment to the curve is Distance(Y , C).However,ift<0, the
distance between the segment and the curve is Distance(P , C).Ift>1, the distance
between the segment and the curve is Distance(P +
d, C).
6.9 Linear Component to Polynomial Curve
First consider the case of computing the distance between a line and a polynomial
curve. Let the line be represented by ˆn · X = c,where ˆn is unit length. The distance
between the line and the polynomial curve X(t) for t ∈ [t
0
, t
1
]occursatat for
which the function F(t)= (ˆn · X(t) − c)
2
is minimized. A numerical minimizer
can be directly applied to F(t), or a calculus approach can be used to compute the
solutions to F
(t) = 0 as potential places where the minimum occurs. In the latter
case, F
(t) =2( ˆn · X(t) − c)(ˆn ·
X
(t)), a polynomial of degree 2n − 1, where the
degree of X(t) is n. A polynomial root finder can be applied to solve this equation.
Localization of the roots can be accomplished using subdivision by variation, just as
was done in computing the distance between a point and a polynomial curve.
If the linear component is a ray, a slight addition must be made to the algorithm.
First, the distance is calculated between the line containing the ray and the curve.
Suppose Y is the closest point on the line to the curve; then Y =P +t
d for some t.
If t ≥ 0, then Y is on the ray itself, and the distance between the ray and the curve
is the same as the distance between the line and the curve. However, if t<0, then
the closest point on the line is not on the ray. In this case the distance from the ray
origin P to the curve must be calculated using the method shown in Section 6.5; call
it Distance(P , C),whereC denotes the curve. The distance between the ray and the
curve is Distance(P , C).
If the linear component is a segment, the distance is first calculated between the
line of the segment and the curve. If Y is the closest point on the line to the curve,
then Y = P + t
d for some t.Ift ∈ [0, 1], then Y is already on the segment, and
the distance from the segment to the curve is Distance(Y , C).However,ift<0, the
distance between the segment and the curve is Distance(P , C).Ift>1, the distance
between the segment and the curve is Distance(P +
d, C).
6.10
GJK Algorithm
We now discuss an effective method for computing the distance between two convex
polygons in 2D. The original idea was developed by E. G. Gilbert, D. W. Johnson, and
S. S. Keerthi (1988) for convex polyhedra in 3D, but the ideas apply in any dimension
to the generalization of convex polyhedra in that dimension. The algorithm has