Implementing a Plane
A plane is a perfectly flat surface that extends infinitely in two dimensions. For simplicity, your ray tracer will implement a plane in xz—that is, extending infinitely far in both x and z dimensions, passing through the origin. Using transformation matrices, though, you’ll be able to rotate and translate your planes into any orientation you like.
Because a plane has no curvature, its normal vector is constant everywhere—it doesn’t change. Every single point on the plane has the same normal: vector(0, 1, 0). This means that implementing the local_normal_at function for the plane is rather uninteresting! Add the following test to check the expected normal vector for a few arbitrary points on the plane. It assumes that the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access