Capped Cylinders

If you’ve played with your new truncated cylinders at all, you’ll have noticed that they’re hollow, like lengths of PVC pipe or empty toilet paper rolls. This can be exactly the effect you need sometimes, but at other times you really want the cylinders to be capped, or closed at each end. To do that, you need to add end caps—discs that exactly cover each end of the cylinder.

These discs are planes that are constrained to the cylinder’s cross-section—and you implemented planes way back in Chapter 9, Planes. While you can’t exactly reuse your plane code for this, the concepts will (hopefully!) look familiar.

You’ll add end caps to your cylinders in three steps:

  1. Add a closed attribute to your cylinders, indicating that the cylinders ...

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.