Implementing a Camera

Just like a real camera, your virtual camera will let you “take pictures” of your scene. You can move it around, zoom in and out, and even rotate the camera upside down if that’s the shot you want. The camera is defined by the following four attributes:

  • hsize is the horizontal size (in pixels) of the canvas that the picture will be rendered to.

  • vsize is the canvas’s vertical size (in pixels).

  • field_of_view is an angle that describes how much the camera can see. When the field of view is small, the view will be “zoomed in,” magnifying a smaller area of the scene.

  • transform is a matrix describing how the world should be oriented relative to the camera. This is usually a view transformation like you implemented in the ...

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.