
656 Chapter 11 Intersection in 3D
to each cylinder. Draw yourself a picture to see that intersection/separation is deter-
mined solely by testing the direction
d =ˆw. Note that this direction does satisfy the
inequality constraints since ˆw ·ˆw
0
= 0, ˆw ·ˆw
1
= 0, and ˆw ·
=ˆw ·
φ =
φ > 0.
The two cylinders are separated if and only if
φ
2
>(r
0
+ r
1
)
2
.
If det(B
0
) = 0 and det(B
1
) = 0, then the columns of B
1
are linearly dependent.
Moreover, one of them must be nonzero. If not, then 0 = ( ˆu ·ˆu
1
)
2
+ ( ˆv ·ˆu
1
)
2
=
1−( ˆw ·ˆu
1
)
2
, which implies |ˆw ·ˆu
1
|=1and ˆu
1
is either ˆw or −ˆw. Similarly v
1
is either
ˆw or −ˆw. This cannot happen since ˆu
1
and v
1
are orthogonal. Let
ψ beanonzero
column of B
1
.Thevector
ζ =
ψ
⊥
satisfies the condition B
T
1
ζ =
0; therefore,
0 =
ζ
T
(r
0
B
0
ˆη
0
+ r
1
B
1
ˆη
1
) = r
0
(B
T
0
ζ)·ˆη
0
If B
T
0
ζ = (a, b), then ˆη
0
=±(b, −a)/
√
a
2
+ b
2
.Thevector ˆη
1
is determined by
ˆη
1
=1 and the linear equation
r
1
(B
T
1
ψ) ·ˆη
1
=−r
0
(B
T
0
ψ) ·ˆη
0
The ˆη
1
are therefore points of intersection, if any, between a circle and a line. The
normalization of ˆη
0
can be avoided by defining p
0
=B
T
0
ζ ˆη
0
and p
1
=B
T
0
ζ ˆη
1
.In
this case p
0
= (B
T
0
ζ)
⊥
and r
1
(B
T
1
ψ) ·p
1
=−r
0
(B
T
0
ψ) ·p
0
. The extraction of (x, y)
discussed later in fact does not require the normalizations. The intersection of line
and circle does require solving a quadratic equation, so a square root has to be
calculated (or the quadratic must be solved iteratively to avoid the cost of the square
root). A similar construction applies if det(B
0
) = 0 and det(B
1
) = 0.
If det(B
0
) = 0 and det(B
1
) = 0, then B
0
is invertible and
ˆη
0
=−(r
1
/r
0
)B
−1
0
B
1
ˆη
1
with ˆη
0
=1 and ˆη
1
=1. The extraction of (x, y) discussed later does not require
unit-length quantities for ˆη
0
and ˆη
1
, so the three equations can be rewritten to avoid
some divisions and normalizations. Rewrite the displayed equation as
r
0
det(B
0
) ˆη
0
=−r
1
Adj(B
0
)B
1
ˆη
1
Define p
0
= r
0
det(B
0
) ˆη
0
, p
1
= r
1
ˆη
1
, and C = Adj(B
0
)B
1
. The equations are now
p
0
=−C p
1
, p
0
2
= r
2
0
det(B
0
)
2
, and p
1
2
= r
2
1
.
The quadratic equations for p
1
are r
2
0
det(B
0
)
2
=p
T
1
C
T
C p
1
and p
1
2
= r
2
1
.Fac-
tor C
T
C = QEQ
T
,whereE = Diag(e
0
, e
1
) are eigenvalues and the columns of Q are
eigenvectors. Let
ψ = Q
T
p
1
. The equations become
ψ
2
= r
2
1
and r
2
0
det(B
0
)
2
=
ψ
T
E
ψ.If
ψ =(a, b), then a
2
+b
2
=r
2
1
and e
0
a
2
+e
1
b
2
=r
2
0
det(B
0
)
2
. These are two
linear equations in the two unknowns a
2
and b
2
. The formal solution is a
2
=(e
1
r
2
1
−
r
2
0
det(B
0
)
2
)/(e
1
−e
0
) and b
2
=(r
2
1
−e
0
r
2
0
det(B
0
)
2
)/(e
1
−e
0
). Assuming both right-
hand sides are nonnegative, you have four solutions (a, b), (−a, b), (a, −b), and