Collision detection between a line and a circle in JavaScript
Here you will need some Math:
This is the basic concept if you don't know how to solve equations in general. I will leave the rest of the thinking to you. ;) Figuring out CD
's length isn't that hard.
If you are asking how, that's how: Finding collisions in JavaScript is kind of complicated.