The LookAt
function is mainly used for 3D graphics. It is a convenient way to position a 3D camera. While graphics programming is outside the scope of this book, for our math library to be practical we need to implement some graphics-related functionality.
Getting a vertex (vector) to become a pixel primarily involves three matrix transformations. The world transform, view transform, and projection transform. All three of these transformations are expressed as a matrix multiplication.
The world transform takes the vertex from model space to world space, we've already implemented this as the
Transform
functionThe view transform takes a vertex from world space and transforms it to eye space, sometimes called view space or camera space
The projection transform takes vertices from eye space and puts them into normalized device coordinates
If we multiply a vertex by the view matrix, the vertex ends up in eye space. Eye space transforms the vertex in the world so it's relative to a camera...