How to derive rotation matrix for quaternion I've been following the Wikipedia article on quaternions and spatial rotations and I've come across something I don't understand:
.
Everything up to this point is clear yet I can't see how the first equation leads to the second. If someone could give a more clear explanation that would be greatly appreciated.
Thanks for any help
 A: It comes down to straightforward manipulations, but a lot of them. First, simplify the scalar term and expand the cross product:
\begin{align}
s(-\mathbf v \cdot \mathbf p q_r + q_r \mathbf v\cdot \mathbf p&,
\mathbf v(\mathbf v \cdot \mathbf p) + q_r^2 \mathbf p + q_r \mathbf v \times \mathbf p + \mathbf v \times (q_r \mathbf p + \mathbf v \times \mathbf p))
\\ & = 
s(0,
\mathbf v(\mathbf v \cdot \mathbf p) + q_r^2 \mathbf p + q_r \mathbf v \times \mathbf p + \mathbf v \times (q_r \mathbf p + \mathbf v \times \mathbf p))
\\ & = 
s(0,
\mathbf v(\mathbf v \cdot \mathbf p) + q_r^2 \mathbf p + q_r \mathbf v \times \mathbf p + q_r\mathbf v \times \mathbf p + 
\mathbf v \times (\mathbf v \times \mathbf p))
\\ & = 
s(0,
\mathbf v(\mathbf v \cdot \mathbf p) + q_r^2 \mathbf p + 2q_r \mathbf v \times \mathbf p+ 
\mathbf v \times (\mathbf v \times \mathbf p)).
\end{align}
Now, rewrite each term as a matrix multiplied by $\mathbf p$:

*

*$\mathbf v(\mathbf v \cdot \mathbf p) = (\mathbf{v \otimes v})\mathbf p$

*$q_r^2\mathbf p = q_r^2 \mathbf I \mathbf p$

*$2q_r \mathbf v \times \mathbf p = 2q_r[\mathbf v]_\times \mathbf p$

*$\mathbf v \times (\mathbf v \times \mathbf p) = [\mathbf v]_\times^2 \mathbf p$.

From there, we simply factor the product.
$$
(\mathbf{v \otimes v})\mathbf p + q_r^2 \mathbf I \mathbf p + 2q_r[\mathbf v]_\times \mathbf p + [\mathbf v]_\times^2 \mathbf p = 
(\mathbf{v \otimes v} + q_r^2 \mathbf I + 2q_r[\mathbf v]_\times + [\mathbf v]_\times^2)\mathbf p.
$$
