You say it's a circle. I assume you know the center (C
) and the radius (r
). So the circle is P == |P - C| = r
, equivalent to <P-C, P-C> = r*r
and finally <P-C, P-C> - r*r = 0
.
You know the line, so you know two points (A
and B
). In parametric equations, it's P == A + t(B-A)
.
For points that are intersections, then, both equations hold true. So you can substitute the second equation in the first one, yielding <A+t(B-A)-C, A+t(B-A)-C> - r*r = 0
. If you expand that dot product, you get a quadratic equation in t (that is, K1*t*t + K2*t + K3 = 0).
If you only need to know whether there are intersections, compute the determinant (K2*K2 - 4*K1*K3
). If that's negative, the line and the circle don't intersect. If it's positive, there are two intersections. If it's zero, the line is tangent to the circle.
If you want to compute the coordinates of the intersection(s), compute the values of t
, and plug them in the parametric line equation to get the coordinates.