Truncating Cylinders
Imagine a world where table legs stretch forever in both directions, where pencils can never be sharpened because they have no end, and where cars roll around on wheels that are infinitely wide. What a mess! Perhaps Salvador Dalí could make something out of that, but for the rest of us, such cylinders are hard to use well. To make them more useful you can truncate them, chopping them off at one or both ends.
For your ray tracer, you’ll implement truncated cylinders by permitting a minimum and a maximum y value to be given for each cylinder. For example, the cylinder only exists between y=-1 and y=2 as shown in the figure.
Note that the extents are exclusive, meaning if the cylinder is truncated at y=2, the cylinder extends ...
Get The Ray Tracer Challenge now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.