Mathematical expression of a rotation I don't understand how my teacher defined an expression for the rotation adding up the two red vectors made up from the strong blue ones after rotation

I especially don't understand how does the transposed vector appears. 
 A: The rotation is of the vector $\mathbf p$ around the axis along $\mathbf u$ by angle $\phi$, where $\|\mathbf u\| = 1$. We start by writing $\mathbf p$ as the sum of two vectors, one parallel to $\mathbf u$ and the other normal  to it:
$$\begin{align}\mathbf p_{\|} &= (\mathbf p\cdot\mathbf u)\mathbf u\\\mathbf p_{\perp} &= \mathbf p - \mathbf p_{\|} = \mathbf p - (\mathbf p\cdot\mathbf u)\mathbf u\end{align}$$
so
$$\mathbf p = \mathbf p_{\|} + \mathbf p_{\perp}$$
and you can confirm easily that $\mathbf u\cdot \mathbf p_{\perp} = 0$.
Now a rotation about $\mathbf u$ has no affect on vectors parallel to $\mathbf u$, so it acts entirely on $\mathbf p_{\perp}$, which rotates to another vector $\mathbf p_{\perp}'$ which is also normal to $\mathbf u$.
To find that rotation, we can establish a coordinate system on the plane normal to $\mathbf u$ by finding two orthogonal unit vectors in that plane to act as the $x$ and $y$ axes. Call the $x$-axis vector $\mathbf v$ and the $y$-axis vector $\mathbf w$. Since $\mathbf p_{\perp}$ is in this plane, we can define $$\mathbf v = \frac{\mathbf p_{\perp}}{\|\mathbf p_{\perp}\|}$$
To get the other vector, recall that the cross-product of two vectors is perpendicular to both. So we can let $$\mathbf w = \mathbf u \times \mathbf v$$
(There is a question of orientation that must be handled carefully - choosing $\mathbf w = \mathbf u \times \mathbf v$ makes $\mathbf v, \mathbf w, \mathbf u$ the $x,y,z$-axis vectors respectively of a right-handed coordinate system, so a 90-degree positive rotation about $\mathbf u$ will carry $\mathbf v$ to $\mathbf w$ (as opposed to $-\mathbf w$ for a negative rotation.)
Now in this coordinate system, a rotation by $\phi$ takes $(1,0)$ to $(\cos \phi, \sin \phi)$. That is, the rotation $\mathbf v'$ of $\mathbf v$ by $\phi$ is given by $$\mathbf v' = \mathbf v\cos\phi + \mathbf w\sin\phi$$
Therefore $$\begin{align}\mathbf p_{\perp}' &= \|\mathbf p_{\perp}\|\mathbf v'\\ &= \|\mathbf p_{\perp}\|\mathbf v\cos\phi + \|\mathbf p_{\perp}\|\mathbf w\sin\phi\\&=\mathbf p_{\perp}\cos\phi + \|\mathbf p_{\perp}\|(\mathbf u \times \mathbf v)\sin\phi\\&=\mathbf p_{\perp}\cos\phi + (\mathbf u \times \mathbf p_{\perp})\sin\phi\end{align}$$
And so finally the rotation $\mathbf p'$ of $\mathbf p$ by $\phi$ about $\mathbf u$ is given by
$$\begin{align}\mathbf p' &= \mathbf p_{\|} + \mathbf p_{\perp}'\\&=(\mathbf p\cdot\mathbf u)\mathbf u + \mathbf p_{\perp}\cos\phi + (\mathbf u \times \mathbf p_{\perp})\sin\phi\\&=(\mathbf p\cdot\mathbf u)\mathbf u + (\mathbf p - (\mathbf p\cdot\mathbf u)\mathbf u)\cos\phi + (\mathbf u \times (\mathbf p - (\mathbf p\cdot\mathbf u)\mathbf u))\sin\phi\\&=\mathbf p\cos\phi + (1-\cos\phi)(\mathbf p\cdot\mathbf u)\mathbf u + (\mathbf u \times \mathbf p)\sin\phi\end{align}$$
since $\mathbf u \times \mathbf u = \mathbf 0$.
The final element comes from the common practice of identifying vectors with $3 \times 1$ column matrices: $$(x, y, z) \equiv \begin{bmatrix}x\\y\\z\end{bmatrix}$$Under this identification, $\mathbf p\cdot\mathbf u = \mathbf u\cdot\mathbf p = \mathbf u^T\mathbf p$. So 
$$\begin{align}(1-\cos\phi)(\mathbf p\cdot\mathbf u)\mathbf u &= \mathbf u(1-\cos\phi)(\mathbf p\cdot\mathbf u)\\&=\mathbf u(1-\cos\phi)\mathbf u^T\mathbf p\\&=\mathbf u\mathbf u^T(1-\cos\phi)\mathbf p\end{align}$$
Which rearrangement he made because he is now going to do the multiplication 
$\mathbf u\mathbf u^T$ first, then apply that matrix to $\mathbf p$. 
In fact, he is prepping to also express the other two terms as matrices multiplying $\mathbf p$, which he can then add together to represent the entire rotation as a matrix operator. The conversion for the first term to matrix form is obvious, but the last term requires some additional development that he may not have done yet.
