Unit quaternions are used to define rotations, and has nothing to do with position. It defines all points in $SO(3)$, the 3D rotation group, and does not suffer from singularity, as in the case of Euler angles.
The quaternion ${\bf q}_1=\cos(\pi/4)+\sin(\pi/4)\bf i$ represents rotation about (not over) the $\bf i$ vector, which in general represents the $x$-axis, by an angle of $\pi/2$. This can be easily understood by the equivalent axis-angle representation. Any quaternion can be written as ${\bf q}=\cos(\phi/2) + \sin(\phi/2){\bf k}$, where ${\bf k}$ is a unit vector representing the axis of rotation and $\phi$ is the angle in radians. Following the logic, the quaternion ${\bf q}_2=\cos(\pi/4)+\sin(\pi/4)\bf k$ represents rotation about the $z$-axis and not $y$-axis.
The equivalent rotation of first performing ${\bf q}_1$ and then ${\bf q}_2$ is given by ${\bf q}_3={\bf q}_2{\bf q}_1$. Note the order of the multiplication. Also, the quaternion multiplication is not commutative. The quaternion multiplication is performed using the following rules:
- ${\bf ij}={\bf k}$, ${\bf jk}={\bf i}$, ${\bf ki}={\bf j}$
- ${\bf ji}={\bf -k}$, ${\bf jk}={\bf -i}$, ${\bf ki}={\bf -j}$
- ${\bf i}^2={-1}$, ${\bf j}^2={-1}$, ${\bf k}^2={-1}$.
Following these rules, one can calculate ${\bf q}_3={\bf q}_2{\bf q}_1=\frac{1}{2}+\frac{1}{2}{\bf i}+\frac{1}{2}{\bf j}+\frac{1}{2}{\bf k}$.
In order to find ${\bf q}_1$ if ${\bf q}_2$ and ${\bf q}_3$ are given, one can write the equation as
${\bf q}_1={\bf q}^{-1}_2{\bf q}_3$.
The inverse of a quaternion ${\bf q}^{-1}_2$ is given by its conjugate.
Hence, ${\bf q}^{'}_1=(\cos(\pi/4)-\sin(\pi/4){\bf k})*(\frac{1}{2}+\frac{1}{2}{\bf i}+\frac{1}{2}{\bf j}+\frac{1}{2}{\bf k})$, $*$ represents quaternion multiplication. This gives ${\bf q}^{'}_1={\bf q}_1$.
Finding the equivalent axis-angle representation:
The norm of the vector component gives $\sin(\phi/2)$ and the scalar component gives $\cos(\phi/2)$. Hence, the angle $\phi=2\operatorname{ArcTan}(\sin(\phi/2),\cos(\phi/2))$. Note the use of ArcTan and the double argument. This gives a unique answer, as opposed to taking ArcCos or ArcSin. The axis vector can then be found by dividing the vector component of quaternion by $\sin(\phi/2)$.
For example, the quaternion ${\bf q}_3$ can be stated as rotation about the unit vector ${\bf v}=\frac{1}{\sqrt{3}}{\bf i}+\frac{1}{\sqrt{3}}{\bf j}+\frac{1}{\sqrt{3}}{\bf k}$ by an angle of $\frac{2\pi}{3}$.
Further references:
Quatenions and spatial rotations (Wikipedia)
Quaternions and Rotations in 3-Space: How it Works
Representing Attitude: Euler Angles, Unit Quaternions, and Rotation
Vectors