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:
- Calculate
Target - Eye
, and normalize. This is yourforward
vector. (X) - Cross
world up
withforward
, and normalize. This generates yourside
vector. (Y) - Cross your
forward
andside
vector. This generates yourlook 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.