Inverting Matrices
If you multiply 5 by 4, you get 20. If you later decide to undo that operation, you can multiply 20 by the inverse of 4 (or 1/4) and get 5 again.
That’s pretty much the idea for matrices, too. If you multiply some matrix A by another matrix B, producing C, you can multiply C by the inverse of B to get A again. You’ll use this approach a lot, starting in Chapter 5, Ray-Sphere Intersections, because inverting matrices is the key to transforming and deforming shapes in a ray tracer.
Inverting matrices is a bit more complicated than inverting numbers, though. You’ll employ a method known as cofactor expansion. If that sounds intimidating, take heart! We’ll approach it nice and slow, one step at a time. Starting with routines ...
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.