How does "get look at rotation" work from a mathematical point of view

A rotation is just the “forward, side, up” vectors of the basis (tripod) stored in the matrix columns (or rows, depending on your convention.)

Look-at is a pretty simple operation:

  1. Calculate Target - Eye, and normalize. This is your forward vector. (X)
  2. Cross world up with forward, and normalize. This generates your side vector. (Y)
  3. Cross your forward and side vector. This generates your look up vector. (Z)

The matrix you just calculated is the forward rotation – taking a camera, point the camera at the target. If you want the reverse rotation – transform an object into the camera’s space – then invert the matrix, which ends up being the same as the transpose for an orthonormal matrix like this.

2 Likes