I have 2 points that form a line, along with a center point for a circle and its radius. The formula for my circle is:
$(x - C_x)^2 + (y - C_y)^2 = r^2 ,$ where $C$ denotes CircleCenter
The formula for my line (since it's 2 points) is:
$(y - y_1) = m (x-x_1),$ where $m = y_2/y_1 - x_2/x_1$
$y = m(x-x_1) + y_1$
I substituted the formula so that all of them are variables of $x$ (substitute formula 2 in 1), then I calculated both values of $x,$ which I then reused in the original formula to calculate the corresponding $y$ values:
$y = m(x - x_1) + y_1,$ where $x$ is the 2 values
The output I'm getting, however, is an projection rather than an intersection, such as the points of intersection are ALWAYS counted even though the points are outside/inside the circle.
Provided pictures with examples.
Incorrect Intersection Picture #1
Incorrect Intersection Picture #2
Edit: I've been asked to post the formulas that I substituted:
$x^2 - 2xC_x + C_x^2 + (m(x-x_1) + y_1)^2 - 2(m(x-x_1) + y_1) C_y + C_y^2 - r^2 = 0$