The basic equation for a straight line is $y = mx + b$, where $b$ is the height of the line at $x = 0$ and $m$ is the gradient. The basic equation for a circle is $(x - c)^2 + (y - d)^2 = r^2$, where $r$ is the radius and $c$ and $d$ are the $x$ and $y$ shifts of the center of the circle away from $(0,\ 0)$.
I'm trying to come up with an equation for determining the intersection points for a straight line through a circle. I've started by substituting the "y" value in the circle equation with the straight line equation, seeing as at the intersection points, the y values of both equations must be identical. This is my work so far:
$$(x - c)^2 + (mx + b - d)^2 = r^2$$ $$x^2 + c^2 - 2xc + m^2x^2 + (b - d)^2 + 2mx(b - d) = r^2$$ I'll shift all the constants to one side $$x^2 - 2xc + m^2x^2 + 2mx(b - d) = r^2 - c^2 - (b - d)^2$$ $$(m^2 - 1)x^2 + 2x(m(b - d) - c) = r^2 - c^2 - (b - d)^2$$
That's as far as I can get. From what I've gathered so far, I ought to be able to break down the left side of this equation into a set of double brackets like so: $$(ex + f)(gx + h)$$ where $e,\ f,\ g$ and $h$ are all constants. Then I simply have to solve each bracket for a result of $0$, and I have my $x$ coordinates for the intersections of my two equations. Unfortunately, I can't figure out how to break this equation down.
Any help would be appreciated.