I'm currently working on a Quaternion Neural Network and I was wondering if a Quaternion rotation was only defined when a Quaternion $q$ is rotated using an unit quaternion $u$ ($uqu^{-1}$), or if the Hamilton product between two Quaternions was a kind of rotation ? The point is to understand how the Hamilton product can be seen in a 3D space to finally understand how Quaternion Neural Networks can perform better.
Thanks a lot !
The quaternions $\mathbb{H}$ are an algebra containing the reals $\mathbb{R}$ and form a four-dimensional real inner product space, with a norm satisfying $|x|^2:=\langle x,x\rangle$ and $|xy|=|x||y|$.
Thus, if $p,q$ are unit quaternions (with $|p|=|q|=1$), the function $f(x):=pxy$ satisfies
$$ |f(x)|=|pxq|=|p||x||q|=|x|. $$
Since $f$ is $\mathbb{R}$-linear and preserves the norm, it is an isometry, and in fact it is a rotation of $\mathbb{H}$, or in other words of four-dimensional space.
If $pq=1$, so we can write $p=u$ and $q=u^{-1}$, the function $f(x)=uxu^{-1}$ satisfies $f(1)=1$ and hence restricts to a rotation of the orthogonal complement of $1$ inside $\mathbb{H}$, which is the three-dimensional subspace of purely imaginary quaternions.
If $|p|=1,q=1$, then $f(x)=px$ is a left-isoclinic rotation of 4D space, and if $p=1,|q|=1$ then $f(x)=xq$ is a right-isoclinic rotation of 4D space.
If $|p|\ne1,q=1$ then $|f(x)|=|p||x|\ne |x|$ so the function $f(x)=px$ does not preserve the norm, hence is not an isometry, so not a rotation. Similarly if $p=1,|q|\ne1$ then $f(x)=xq$ is not a rotation. On the other hand, if $|p||q|=1$ then $f(x)=pxq$ does preserve the norm, and in that case we can simply normalize $p$ and $q$ to be unit quaternions (replace $p$ with $p/|p|$ and $q$ with $q/|q|$) so there is no generality lost by using unit quaternions.