Download Source: ****HERE**** Here is a demo of some capsule-line collision I whipped up. One thing I am proud of is I made a formula that finds the intersection of a circle using the function graph of a circle.
Basically, if you take a ray and want to know where that ray intersects the circle:
The ray pointing towards the circle: rP = ray point. rV = ray vector.
The circle: CP = center point of circle. cr = radius of circle.
: Take negative receprocal of rV to get perpendicular vector pV. : combine pV with CP to get a perpendicular at center of circle. : set rays [rP rV] and [CP pV] equal to each other and find intersection using point-normal form. Call this intersection RC : Find distance: intersection to circle center. Call this distance DS. : Divide DS by the cr to get a value from 0 to 1. : Input this 0to1 value into the function graph of a circle: : Take the y-height output and scale it up by the radius (cr) of the circle. Call this value SKA. : Flip the sign of normalized rV. Translate it to the intersection point RC. : Intersection on circle = RC+(SKA*normalized_rV);