Math: Points of Secancy

Math time :king:

I’m working on a few AS2.0 classes for basic coordinate geometry and quadratic functions but my math knowledge has now reached it’s limit.

Given the equation of a circle: (x - h)² + (y - k)² = r²
and the equation of a line: y = mx + b
and the quadratic equation: x = (-b ±√(b² - 4ac)) / 2a

I came up with a few equations for determining the points of secancy of a line on a circle:
(1 + m²)x² + (-2h + 2mx)x + (h² + z² -r ²)

Then plug that into the quadratic equation and we have the x coordinate of both points.

To find the y coordinate of each point, I have this equation:
y = ±√(r² - (x - h)²) + k
Where x is one of the points found earlier. So far so good.

The last equation gives you two values since the square root of a number has two answers (a positive and negative one) which makes sense since on a circle there are two possible points for each x value. How do you determine which one is the right one use. I was thinking I could check to see if each point lies on the secant and determine which ones are the right values - is this the right way to go.

Thanks :sc: