First intersection of the segment a→b with a sphere, as the parameter s ∈ [0, 1] where contact begins (a + s·(b−a)), or null if the segment never
touches the sphere. If a already lies inside, returns 0.
Solves |a + s·d − c|² = r² (a quadratic in s) and returns the entry root
that falls within the segment. A degenerate segment (a == b) reduces to a
point-in-sphere test.
First intersection of the segment
a→bwith a sphere, as the parameters ∈ [0, 1]where contact begins (a + s·(b−a)), ornullif the segment never touches the sphere. Ifaalready lies inside, returns0.Solves
|a + s·d − c|² = r²(a quadratic ins) and returns the entry root that falls within the segment. A degenerate segment (a == b) reduces to a point-in-sphere test.