Circle line-segment collision detection algorithm?

前端 未结 28 1749
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 06:38

I have a line from A to B and a circle positioned at C with the radius R.

\"Image\"

What is a good alg

28条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 07:14

    No one seems to consider projection, am I completely off track here?

    Project the vector AC onto AB. The projected vector, AD, gives the new point D.
    If the distance between D and C is smaller than (or equal to) R we have an intersection.

    Like this:
    Image by SchoolBoy

提交回复
热议问题