Here is some code i wrote up detecting where a parametric line hits a circle.
if you draw a line with the circle as the origin to A and B, that line is perpendicular to the line you control by clicking, and it's distance is how close the closest point on the line is to the circle.
I'm using this code and the last couple ones to make mah own 2d collision system.
x1 as float
y1 as float
x2 as float
y2 as float
x3 as float
y3 as float
x4 as float
y4 as float
x10 as float
y10 as float
Q as float
R as float
A as float
B as float
circlex as float
circley as float
radius as float
x1=rnd(screen width())
y1=rnd(screen height())
x2=rnd(screen width())
y2=rnd(screen height())
circlex=rnd(screen width())
circley=rnd(screen height())
radius=40
white as dword
green as dword
red as dword
white=rgb(255,255,255)
green=rgb(0,255,0)
red=rgb(255,0,0)
do
cls
if mouseclick()=1
x1=mousex()
y1=mousey()
endif
if mouseclick()=2
x2=mouseX()
y2=mousey()
endif
if spacekey()
circlex=mousex()
circley=mousey()
cls
endif
y4=y2-circley
y3=y1-circley
x4=x2-circlex
x3=x1-circlex
x10=x4-x3
y10=y4-y3
B=y10*(x3*y10-y3*x10)/(y10^2+x10^2)
if y10=0
A=y1-circley
else
A=-x10*B/y10
endif
D#=A^2+B^2
if x10=0
t#=(A-y3)/y10
else
t#=(B-x3)/x10
endif
ink red,0
line -10*(x2-x1)+x1,-10*(y2-y1)+y1,10*(x2-x1)+x1,10*(y2-y1)+y1
ink green,0
line x1,y1,x2,y2
line circlex,circley,B+circlex,A+circley
if D#<=radius^2 and t#>0 and t#<1
circle circlex,circley,radius
else
ink white,0
circle circlex,circley,radius
endif
`print D#
`print A
`print B
sync
loop