To rotate about the $z$ axis (yaw) by $\alpha$ you need the following quaternion
$\begin{aligned}q = \begin{bmatrix}\cos(\tfrac{\alpha}{2})\\0\\0\\\sin(\tfrac{\alpha}{2})\end{bmatrix}\end{aligned}\tag{1},$
to rotate about the $x$ (pitch) axis you need
$\begin{aligned}q = \begin{bmatrix}\cos(\tfrac{\alpha}{2})\\0\\ \sin(\tfrac{\alpha}{2})\\0\end{bmatrix}\end{aligned}\tag{2},$
and to rotate about $y$ by $\alpha$ you need
$\begin{aligned}q = \begin{bmatrix}\cos(\tfrac{\alpha}{2})\\\sin(\tfrac{\alpha}{2})\\0\\0\end{bmatrix}\end{aligned}\tag{3}.$
If you have a rotation described by the Euler angles $(\phi, \theta, \psi)$ (in the standard order), then, the corresponding quaternion is
$\begin{aligned}
q = \begin{bmatrix}
\cos \tfrac{\phi}{2} \cos \tfrac{\theta}{2} \cos \tfrac{\psi}{2} + \sin \tfrac{\phi}{2} \sin \tfrac{\theta}{2} \sin \tfrac{\psi}{2} \\
\sin \tfrac{\phi}{2} \cos \tfrac{\theta}{2} \cos \tfrac{\psi}{2} - \cos \tfrac{\phi}{2} \sin \tfrac{\theta}{2} \sin \tfrac{\psi}{2} \\
\cos \tfrac{\phi}{2} \sin \tfrac{\theta}{2} \cos \tfrac{\psi}{2} + \sin \tfrac{\phi}{2} \cos \tfrac{\theta}{2} \sin \tfrac{\psi}{2} \\
\cos \tfrac{\phi}{2} \cos \tfrac{\theta}{2} \sin \tfrac{\psi}{2} - \sin \tfrac{\phi}{2} \sin \tfrac{\theta}{2} \cos \tfrac{\psi}{2}
\end{bmatrix}
\end{aligned}\tag{4}.$
If you are rotating your object about an axis described by the vector $u=(u_x, u_y, u_z)\in\mathbb{R}^3$ and by an angle $\alpha$ about that axis, then
$\begin{aligned}q = \begin{bmatrix}\cos(\tfrac{\alpha}{2})\\\sin(\tfrac{\alpha}{2})u\end{bmatrix}=
\begin{bmatrix}\cos(\tfrac{\alpha}{2})\\\sin(\tfrac{\alpha}{2})u_x\\\sin(\tfrac{\alpha}{2})u_y\\\sin(\tfrac{\alpha}{2})u_z\end{bmatrix}
\end{aligned}
\tag{5}.$
What if you needed to do one rotation followed by another rotation? Like 30 degrees around the y axis followed by 90 around the x axis? Do you just combine them in a single quaternion eg (cos(15*45) + i sin(45) + j sin (15) or do you need to multiply them?
– Quiet Oct 27 '15 at 01:44