Intersection between a line and a sphere
I'm trying to find the point of intersection between a sphere and a line but honestly, I don't have any idea of how to do so. Could anyone help me on this one ? Express the line as an function of t : { x(t) = x0*(1-t) + t*x1 { y(t) = y0*(1-t) + t*y1 { z(t) = z0*(1-t) + t*z1 When t = 0 , it will be at one end-point (x0,y0,z0) . When t = 1 , it will be at the other end-point (x1,y1,z1) . Write a formula for the distance to the center of the sphere (squared) in t (where (xc,yc,zc) is the center of the sphere): f(t) = (x(t) - xc)^2 + (y(t) - yc)^2 + (z(t) - zc)^2 Solve for t when f(t) equals R^2 (