# General Formula for a Line Intersecting a Circle

This is the equation of a circle:
(x - i)2 + (y - j)2 = r2

Where i and j is the coordinate of the center of the circle (x and y, respectively). They act as a translation of the circle from the origin.

This is the equation of a line:
y = mx + k

Where m is the slope of the line and k is the y-intercept of the line.

To find the equation of the intersection, substitute in y = mx + k into (x - i)2 + (y - j)2 = r2

r2 = (x - i)2 + (y - j)2
r2 = x2 - 2xi + i2 + y2 - 2yj + j2
r2 = x2 - 2xi + i2 + (mx+k)2 - 2(mx+k)j + j2
r2 = x2 - 2xi + i2 + m2x2 + 2mkx + k2 - 2mjx - 2kj + j2
0  = x2 + m2x2 - 2xi - 2mjx + 2mkx - 2kj + i2 + j2 + k2 - r2
0  = (m2 + 1)x2 + (-2i - 2mj + 2mk)x + (i2 + j2 + k2 - r2 - 2kj)

So the the coefficients (looking at the general quadratic equation ax2 + bx + c = 0) are:
a = m2 + 1
b = -2i - 2mj + 2mk
c = i2 + j2 + k2 - r2 - 2kj

And all of those variables are known values once we have our circle and line equations, so the coefficients can be used in the quadratic formula to find the points of intersection.

$x= −b± b2−4ac 2a$ $x= −(−2i − 2mj + 2mk)± (− 2 i − 2 m j + 2 m k ) 2 − 4 ( m 2 + 1 ) ( i 2 + j 2 + k 2 − r 2 − 2 jk ) 2 ( m 2 + 1 )$ Where:
x is the x-coordinate of the point of intersection of the line and the circle
i and j is the coordinate of the center of the circle (x and y, respectively)
r is the radius of the circle
m is the slope of the line
k is the y-intercept of the line

And then just sub in m, x and k into the function y = mx + k to find the y-coordinate of the point of intersection of the line and the circle. Then, you will have the entire point.

## Here's a calculator to do it for you!

(x - i)2 + (y - j)2 = r2
y = mx + k

i:     j:     r:

m:     k: