# Rotation matrices vs quaternions?

It seems we can describe every rotation in $$SO(3)$$ by at least one unit vector axis $$u$$ and angle $$\theta$$ pair.

Each of these pairs can also be described by a rotation matrix:

I've heard quarternions can also be used to achieve the same goal.

How do you translate from the $$(u, \theta)$$ representation of a rotation to a quaternion representation?

How do you use the quaternion representation of a rotation to rotate some point $$P \in R^3$$ about the origin?

The relation is as follows: Given the rotation angle $$\theta$$ and the unit vector (axis) $$\mathbf{u}$$, you have to form the quaternion $$\mathbf{q}=\cos\frac{\theta}{2}+\sin\frac{\theta}{2}\mathbf{u}.$$ Then the double-sided action $$R(\mathbf{v})=\mathbf{q}\mathbf{v}\mathbf{q^*}$$ (where $$\mathbf{q^*}$$ is the conjugate quaternion and the operation is quaternion multiplication) gives you the rotated vector.
I'll expand on the existing answer a little. Write $$c:=\cos\frac{\theta}{2},\,s:=\sin\frac{\theta}{2},\,q=c+su$$ with $$u^2=-1$$. The most general form of $$v$$ is $$A+Bu+Cw$$ with $$w^2=-1,\,[u,\,w]=0$$ (if we identify imaginary quaternions with $$3$$-dimensional vectors in the obvious way, the last condition is $$\vec{u}$$'s orthogonality to $$\vec{w}$$). The $$A+Bu$$ part belongs to the same representation in $$\Bbb H$$ of $$\Bbb C$$ as do $$q,\,q^\ast$$, so commutes with them, viz. $$q(A+Bu)q^\ast=A+Bu.$$On the other hand, $$(c+su)Cw(c-su)=(c+su)(cCw+sCuw)=(c^2-s^2)Cw+2csCuw.$$In terms of $$\Bbb R^3$$, this is $$(\cos\theta)C\vec{w}+\sin\theta\vec{u}\times C\vec{w}.$$Note that $$R_{ij}-\delta_{ij}=(1-u_i u_j)(1-\cos\theta)-\epsilon_{ijk}u_k\sin\theta$$.