Quaternion rotationmatrix

I'm a last year student at a high school in Denmark, and I'm trying to understand how quaternions rotations can be described through a rotationmatrix. As of now, I quite don't understand how I go from tre quaternion: q = a + bi + cj + dk, to a quaternion written on matrix form. I now the quaternion can be written as a structure consisting of the real part and a vector (a, v), where the vector represents the imaginary part of the quaternion, but I don't quite understand how I from the vector part of the can describe a rotation with a rotationmatrix.

I hope the question makes sense, english isn't my strongest.

The $$x,y,z$$ unit vectors $$e_1, e_2, e_3$$ of $$\mathbb R^3$$ are represented by $$i,j,k$$, respectively. You have a quaternion $$q$$ such that $$x\mapsto qxq^{-1}$$ is your rotation.
So in particular, pay attention to $$v_1=qiq^{-1}$$, $$v_2=qjq^{-1}$$ and $$v_3=qkq^{-1}$$. Each $$v_i$$ is a quaternion, a linear combination of $$i,j,k$$, and now extract their coefficients of $$v_i$$ into a $$3\times 1$$-vector $$\vec{v_i}$$.
Let $$T$$ be the matrix whose first column is $$\vec{v_1}$$, second column is $$\vec{v_2}$$ and third column is $$\vec{v_3}$$. Are you surprised to learn we're already done?
Look at what has been produced: $$x\mapsto Tx$$ ($$x$$ a column vector), and $$x\mapsto qxq^{-1}$$ ($$x$$ a quaternion with real part zero) are both $$\mathbb R$$-linear transformations, the first one on $$\mathbb R^3$$ and the second on the quaternions with real part zero. When you compute the image of a vector using either method, you always get results that agree (remember, you only have to know that they agree on the basis vectors!)