8.5 Lines Tangent to Two Circles 293
The point P can be chosen on the line containing C
0
and C
1
, the centers of the
circle. Let P = (1 − s)C
0
+ sC
1
, for some s, and let w = C
1
− C
0
. Then
P − C
0
= s w
P − C
1
= (s − 1) w
If we substitute these back into Equations 8.3 and 8.4 we get
r
2
0
= s
2
(w
2
− (
ˆ
d ·w)
2
)
r
2
1
= (s − 1)
2
(w
2
− (
ˆ
d ·w)
2
)
So r
2
0
/s
2
= r
2
1
/(s −1)
2
,or
(r
2
1
− r
2
0
)s
2
+ 2r
2
0
s −r
2
0
= 0
If the two circles have the same radius (that is, r
0
=r
1
), then s =1/2, and thus P is the
midpoint of the line segment between C
0
and C
1
, the centers of the circles. Moreover
(
ˆ
d ·w)
2
=w
2
− 4r
2
0
= a
2
> 0
and so
ˆ
d ·w = a (of course, we could use −a as the root, but this just leads to a
direction vector with the opposite sign). If we let
ˆ
d = (d
0
, d
1
), then
ˆ
d ·w =a is the
equation for a line. The constraint
ˆ
d
2
=1 corresponds to a circle. The two together
represent the intersection of a line with a circle. Either solution will do.
Let w =(w
0
, w
1
). Then w
0
d
0
+ w
1
d
1
= a and d
2
0
+ d
2
1
= 1. If |w
0
|≥|w
1
|, then
d
0
= (a −w
1
d
1
)/w
0
and
(w
2
0
+ w
2
1
)d
2
1
− 2aw
1
d
1
+ a
2
− w
2
0
= 0
If |w
1
|≥|w
0
|, then d
1
= (a −w
0
d
0
)/w
1
and
(w
2
0
+ w
2
1
)d
2
0
− 2aw
0
d
0
+ a
2
− w
2
1
= 0
In either case, the two roots lead to two direction vectors for the tangent lines.
If r
0
>r
1
, the quadratic in s has two real-valued solutions. From the geometry,
one of the values must satisfy 0 <s<1 and produces the two tangents that intersect
each other between the two circles (L
2
and L
3
in the “Four tangents” case in Fig-
ure 8.7). The other root cannot be s = 0 (otherwise P would be at a circle center,
which is not possible).
Foreachroots, the same idea as in the case r
1
=r
0
works. The quadratic to solve
is
(
ˆ
d ·w)
2
=w
2
− r
2
0
/s
2
= a
2
> 0