Collision detection between a line and a circle in JavaScript

前端 未结 4 1582
故里飘歌
故里飘歌 2020-12-06 18:57

I\'m looking for a definitive answer, maybe a function cos I\'m slow, that will determine if a line segment and circle have collided, in javascript (working with canvas)

4条回答
  •  無奈伤痛
    2020-12-06 19:37

    Here you will need some Math:

    enter image description here 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: enter image description here Finding collisions in JavaScript is kind of complicated.

提交回复
热议问题