Quaternions provide a mathematical notation for representing object orientations and rotations in 3D. They are simpler to compose than Euler angles and avoid issues like gimbal lock. Quaternions also have better numerical stability than rotation matrices and may be more computationally efficient. A quaternion is represented as a + bi + cj + dk, and can be converted to and from a rotation matrix. The trace of a matrix is the sum of its main diagonal, and is used to choose the diagonal element of largest absolute value for a robust conversion method between quaternions and matrices.