Rotation in three dimensions

This application calculates the three-dimensional rotation of a point $p$ around an arbitrary axis. In three dimensions, the rotation axis can be determined from a directed line or a direction vector $\vec v$ and a (fixed) point $f$ which $\vec v$ goes through. The rotation is calculated using quaternion as follows. Let $P$ and $F$ be (pure imaginary) quaternions with $p$ and $f$ as vector parts, $\theta$ be the angle of rotation (positive for counterclockwise rotation), and unit quaternion of $\vec v$ defined as \[u=\cos\left(\frac{\theta}{2}\right)+\sin\left(\frac{\theta}{2}\right)\cdot\frac{\vec v}{\|\vec v\|}\] then 3D rotation is calculated from the formula \[ F+u(P-F)u^{-1} \] Note that for unit quaternion $u^{-1}=\overline{u}$, the quaternion conjugate of $u$.

3D Rotation Calculator