Exercise 2: Why Grazing Rays Show the Worst Ray-Sphere Precision Errors — Possible Solution ==================================================================== WHAT MAKES A GRAZING RAY DIFFERENT FROM A DEAD-CENTER RAY ------------------------------ A ray that hits a sphere dead-on through its center enters and exits at two points that are far apart - roughly a full diameter apart, in fact - so the two roots of the quadratic (the near and far intersection distances) are very different in magnitude. A ray that just barely grazes the edge of a sphere at a shallow angle, by contrast, enters and exits very close together - the two intersection points are nearly the same point, meaning the two roots of the quadratic are nearly EQUAL to each other. CONNECTING THIS TO THE VERIFIED NUMERICAL FINDING ------------------------------ This chapter's own worked example showed the naive quadratic formula is dangerous specifically when subtracting two nearly-equal numbers - per Numerical Methods & Floating-Point Computation's own Chapter 4, this is catastrophic cancellation. A dead-center ray's two roots are far apart, so there's no cancellation danger in computing either one via the naive formula - this chapter's own verified example actually showed the FAR root (the one computed via addition rather than subtraction) staying accurate regardless of which formula was used. A grazing ray's two roots being close together is the exact scenario where the naive formula's subtraction step can lose significant precision, since the discriminant itself becomes small (approaching zero as the ray becomes more and more tangent), and computing -b minus a value that's very close to |b| in magnitude is precisely the dangerous cancellation pattern this chapter and its prerequisite verified. WHAT THIS MEANS FOR THE RENDERED IMAGE ------------------------------ A grazing intersection is also visually the hardest case to render correctly even in principle (the surface normal there is nearly perpendicular to the ray, making shading very sensitive to the exact hit point, per this course's own Chapter 4 lighting material) - so the naive formula's worst numerical errors land exactly on the pixels that were already the most visually delicate, compounding a numerical weakness with a rendering weakness in the same place. WHY THIS WORKS AS AN ANSWER ------------------------------ The explanation identifies the specific geometric property (near and far intersection points converging together for a grazing ray) that maps directly onto this chapter's own verified cancellation-prone scenario (two nearly-equal roots), rather than treating "grazing rays are worse" as an unexplained rule of thumb, and connects the numerical issue to why it's especially costly precisely at grazing angles from a rendering-quality standpoint too.