Intersection of a line and a circle
Introduction
Fig.1. App to calculate the intersection points P1 and P2 of a line and a circle.
Given: line parameters a, b and c and circle center and circle radius r.
General linear equation with two variables:
We can write this as an equation of a straight line like:
with:
In case b ≠ 0, m is called the slope or gradient of the line and y0 is called the y-intercept. If b = 0, the line is a vertical line.
General circle equation:
⇔ [1]
If b ≠ 0:
Substituting line equation in [1] results in an equation of the form:
This equation's solutions for x are the x-coordinates of the intersection points :
with:
Let :
- If D < 0, then has no solutions; line does not intersect.
- If D = 0, then has exactly one solution; line is tangent to circle.
- If D > 0, then has two solutions; line intersects at two points.
If b = 0:
Substituting vertical line equation x = k in [1] results in an equation of the form:
This equation's solutions for y are the y-coordinates of the intersection points :
with:
Let :
- If D < 0, then has no solutions; line does not intersect.
- If D = 0, then has exactly one solution; line is tangent to circle.
- If D > 0, then has two solutions; line intersects at two points.