Implementing quaternion based rotations