Cylinders Sept 15, 2019 6:26:55 GMT
Post by chrisd on Sept 15, 2019 6:26:55 GMT
I had a couple of problems with Cylinders (now solved), so I was digging a little deeper into how they work.
First problem: I noticed that for Spheres, there is a test for "A ray originates inside a sphere". It still results in 2 intersections (which applies to Cylinders, as well, but there is no equivalent test). You mention (emphasis mine), "Yes, the ray actually extends behind the starting point, but let’s not get distracted by definitions! Go ahead and write the following test, showing that when the ray starts at the center of a sphere, the first intersection is behind the ray’s origin, and the second is in front of it." The one behind the origin has t < 0.
I wonder if you could elaborate on why you'd want two intersections. If t < 0, could the intersection not be included? (I tried dropping them out for Cylinders, and the refractions for the Cylinders scene description didn't work right, but I haven't gone down that rabbit hole to figure out why.)
Second problem: For Cylinders, after refactoring out common portions of Cone and Cylinder, I had a problem where the radius of the cylinder cap wrong (I had it set to maximum or minimum unconditionally, instead of 1 for Cylinder). If you have a P1.1 version of the book brewing, I suggest the following additional Examples in the "Intersecting the caps of a closed cylinder" Scenario Outline:
# Cylinder lid size
| 6 | point(0, 0.5, 0.999) | vector(0, 1, 0) | 2 |
| 7 | point(0, 0.5, 1.001) | vector(0, 1, 0) | 0 |