[Math] General solution for intersection of line and circle

analytic geometrycircleslinear algebravectors

If the equation for a circle is $|c-x|^2 = r^2$ and the equation for the line is $n \cdot x=d $, and assuming that the circle and line intersect in two points, how can I find these points?

Also as kind of a side note, is there also a general formula for obtaining the equation of a circle of the intersection of a plane and sphere in $\mathbb R^3$, using similar equations?

Best Answer

The answer given by Seyhmus is fine if the line is a line through the origin (or $d = 0$ in your formula). Perhaps a better solution, in the general case, is to find the interserction of a circle $|c - x|^2 = r^2$ with a parametric line, $$ x(t) = a + tb $$ where $a$ is a point and $b$ is a vector.For a point on this line to satisfy the equation, you need to have $$ (tb + (a-c)) \cdot (tb + (a-c)) = r^2 $$ which is a quadratic in $t$: $$ |b|^2 t^2 + 2(a-c)\cdot b t + (|a-c|^2 - r^2) = 0 $$ whose solutions are $$ t = \frac{-2(a-c)\cdot b \pm \sqrt{[2(a-c)\cdot b]^2 - 4|b|^2(|a-c|^2 - r^2)}}{2|b|^2} $$ Once you find these two values of $t$ and plug them back intot he parametric equation, you get your two points.

Coincidentally, this method works fine in all dimensions (i.e., $c$ and $a$ can be points of $R^3$, and $b$ a vector in $R^3$), and the same formula works.

In two dimensions, it's pretty easy to convert from the implicit form of the line to the parametric form: find any two points $P$ and $Q$ on the line, and let $a = P$ and $b = (Q - P)$. In three dimensions, it's rather difficult to specify a line implicitly, but quite simple to express it parametrically, so the general case tends to be asked in exactly the form in which I've answered it.