I'm trying to figure out the collision point of the circle and a line, ultimately it should work in 3D but for now just in 2D to simplify the problem as much as possible.
I've created 2 examples here on what I'm trying to achieve, I want to find point B and D and it should work both the examples below.
PS. this problem is probably harder to solve than it initially looks like.
//edit Radius = 50;
A.x = 70
A.y = 100
B.x = ?
B.y = ?
C.x = -60
C.y = -70
D.x = ?
D.y = ?
E.x = -200
E.y = 0
F.x = 200
F.y = 0
AC_vector = [-130, -170] ---> (= C-A = [((-60)-70), ((-70)-100)] )
AC_distance = 214.009 ---> = √((A.x - C.x)^2 + (A.y - C.y)^2) = sqrt((70 - -60)^2 + (100 - -70)^2)
AC_vectorN = [-0.607451, -0.794359] ---> = AC_vector/AC_distance = [-130/214.009, -170/214.009] // AC_vector normalized
EF_vector = [400, 0] ---> = ( E-F = [(200-(-200)), ((0-0)] )
EF_distance = 400 ---> = √((E.x - F.x)^2 + (E.y - F.y)^2) = sqrt((-200 - 200)^2 + (0 - 0)^2)
EF_vectorN = [1, 0] ---> = EF_vector/EF_distance = [400/400, 0/400] // EF_vector normalized
N = [0, 1] // (surface normal) perpendicular vector of normalized EF
Solution:
Edit// This is what I have figured out so far:
The distance between B and D is always the radius (50)
The vector of BD is the normal of EF (90deg rotaition of EFvector)
So B = D + N*R?
Last part of the solution can be found here: right triangle in 3D space, vectors, line intersection?
And here is the result of the solution: https://youtu.be/1MiwtA329tQ




See the picture that complements the comment. Thought this could help. Point G (red) is the center of the disc at collision. remember to select the proper collision point - there are two.