Head rotation from local to world coordinates

euler angles are a terrible idea.

nobody can ever agree on the order in which these rotations are composed or which axis is which.

just work with a rotation matrix, or an axis-angle encoding. misunderstandings are impossible with those.