If E is the starting point of the ray, .. and L is the end point of the ray, .. and C is the center of sphere you're testing against. .. and r is the radius of that sphere.