Solution (source code)

= Solution
{c}

Decompose $\mathbf v$ by <orthogonal projection> onto the <straight line> spanned by $\mathbf n$ and its <orthogonal complement>:
$$
\mathbf v=(\mathbf v\cdot\mathbf n)\mathbf n+\mathbf w,\qquad \mathbf w=\mathbf n\times(\mathbf v\times\mathbf n).
$$
The first term is fixed by the <rotation>. If $\mathbf w\ne0$, the <vectors> $\mathbf w/|\mathbf w|$ and $(\mathbf n\times\mathbf w)/|\mathbf w|$ form an <orthonormal basis> of the perpendicular <plane>, oriented in the positive sense about $\mathbf n$. A <planar rotation> through $\theta$ therefore sends
$$
\mathbf w\longmapsto\cos\theta\,\mathbf w+\sin\theta\,(\mathbf n\times\mathbf w).
$$
Here $\mathbf n\times\mathbf w=\mathbf n\times\mathbf v$. Adding the fixed parallel component proves the <Rodrigues rotation formula> in the required form:
$$
\boxed{R(\mathbf v)=(\mathbf v\cdot\mathbf n)\mathbf n+\sin\theta(\mathbf n\times\mathbf v)+\cos\theta\bigl(\mathbf n\times(\mathbf v\times\mathbf n)\bigr).}
$$
When $\mathbf w=0$, both perpendicular terms vanish, so the same formula fixes $\mathbf v$ as required. Positive <angles> use the right-hand convention about $\mathbf n$.