If you want the intersection points as well, I use the following for a line a*x+b*y+c=0
.
IntersectLineCircle[{a_, b_}, c_, Circle[{u_, v_}, r_]] :=
Module[{f = (a^2 + b^2) r^2 - (c + a u + b v)^2},
If[N[f] < 0., {{}, {}},
If[N[a] =!= 0.,
f = Sqrt[f] Abs[a];
1/(a^2 + b^2)
{{(a b^2 u - a^2 (c + b v) - b f)/a, -b (c + a u) + a^2 v + f},
{(a b^2 u - a^2 (c + b v) + b f)/a, -b (c + a u) + a^2 v - f}},
{{u - (Sqrt[-(c + b (v - r)) (c + b (r + v))] Abs[b])/b^2, -(c/b)},
{u + (Sqrt[-(c + b (v - r)) (c + b (r + v))] Abs[b])/b^2, -(c/b)}}
]]]
Example graphic.
With[{a = 3, b = -3, c = 4, u = 2, v = -4, r = 6},
Graphics[{Thick, EdgeForm[{Thick, Black}],
Darker@Green, Disk[{u, v}, r],
Red, Line[{x, (a x + c)/(-b)} /. {{x -> -1.5 r}, {x -> 1.2 r}}],
Blue, PointSize[0.02],
Point[IntersectLineCircle[{a, b}, c, Circle[{u, v}, r]]]
}, Frame -> True]]
If there is no intersection of the line and circle, then IntersectLineCircle
returns {{},{}}
.