
15.4 Linear Component and Sphere 701
{
// Ray is directed away from the sphere.
return false;
}
float discr = a1 * a1 - a0;
return discr >= 0;
}
15.4.3 Segment and Sphere
The test-intersection query for a segment versus sphere is slightly more complicated
algebraically than that of ray or line versus sphere, but the end result requires only a
minimum of calculation time. If a
0
≤0, then the segment center P is inside the sphere
and we have an intersection. Otherwise, P is outside the sphere. If = a
2
1
− a
0
< 0,
the line containing the segment does not intersect the sphere, so neither does the
segment. If both of these tests do not provide a quick out, we have ...