Rotation

Multiplying a tuple by a rotation matrix will rotate that tuple around an axis. This can get complicated if you’re trying to rotate around an arbitrary line, so we’re not going to take that route. We’re only going to deal with the simplest rotations here—rotating around the x, y, and z axes.

Trigonometric Functions

images/aside-icons/tip.png

Rotation matrices depend on the sine and cosine functions from trigonometry. Don’t worry about dredging your high school math memories, though. Check your implementation language for a Math namespace, where you will usually find the functions named sin and cos.

The rotation will appear to be clockwise around the corresponding ...

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.