[Math] Quaternions in spherical coordinates

quaternionsrotations

A $\mathbb{R^2}$ unit vector can be expressed as a complex number, using a $\textit{spiral phase quadrature}$ ( Larkin 2001 ):
$$(x,y)\in\mathbb{R^2} \longrightarrow z \in \mathbb{C} =x+iy = e^{i\theta}$$
where $\theta$ has the same meaning than the $\theta'$ from polar coordinates.

Would it possible to express a $\mathbb{R^3}$ unit vector as a quaternion?
$$(x,y,z)\in\mathbb{R^3} \longrightarrow q \in \mathbb{H} =ix + jy +kz = e^{j\theta}e^{k\phi}$$
where $\theta$ and $\phi$ are equivalent to $\theta'$ and $\phi'$ from spherical coordinates.

I know that an unit quaternion can be expressed as:
$$q = e^{i\alpha/2}e^{k\beta/2}e^{j\gamma/2} $$
where $ \alpha$, $\beta$ and $\gamma$ are the Euler angles.
but I would prefer to work in spherical coordinates. Is there an analogy to the spiral phase in 3D?

Best Answer

Let's work out your proposed mapping:

\begin{align} e^{j\theta}e^{k\phi} &= (\cos\theta + j\sin\theta)(\cos\phi + k\sin\phi) \\ &= \cos\theta\cos\phi + (j\sin\theta)(k\sin\phi) + (j\sin\theta)\cos\phi + (\cos\theta)(k\sin\phi) \\ &= \cos\theta\cos\phi + i\sin\theta\sin\phi + j\sin\theta\cos\phi + k\cos\theta\sin\phi \\ \end{align}

Now, since we know $q = e^{i\alpha/2}e^{k\beta/2}e^{j\gamma/2}$ is a unit quaternion, it follows that $e^{j\theta}e^{k\phi}$ also is a unit quaternion (just set $\alpha = 0, \beta = 2\phi, \gamma = 2\theta)$; but since it has a non-zero real part (except when $\cos\theta=0$ or $\cos\phi=0$), the imaginary part $ix + jy + kz$ generally will not correspond to a unit vector in $\mathbb R^3.$

In fact, an even more obvious problem is that if $\theta = 0,$ as $\phi$ varies freely we get a set of vectors whose imaginary parts are all in one direction, while if $\phi = 0,$ as $\theta$ varies we get a set of vectors whose imaginary parts are all in a different direction. In spherical coordinates we can have only one coordinate such that setting that coordinate to zero forces the vector to be in a particular direction.


But let's consider the interpretation of a quaternion as a rotation. It is well-known that a rotation by $\theta$ radians around the axis through the origin in the direction of the unit vector $\hat{\mathbf u}$ can be represented by a unit quaternion $q = q_0 + \mathbf q,$ where $q_0 = \cos(\theta/2)$ is real and $\mathbf q = (\sin(\theta/2))\hat{\mathbf u}$ is the imaginary part of the quaternion interpreted as a vector. The rotated image $v'$ of a three-dimensional vector $v$ (interpreted as the imaginary part of a quaternion) is computed by $v' = qvq^*,$ where $q^* = q_0 - \mathbf q$ is the conjugate of $q.$

A rotation by $\alpha$ radians around the $x$-axis (or respectively around the $y$- or $z$-axis) is therefore represented by the quaternion $\cos\frac\alpha2 + i\sin\frac\alpha2 = e^{i\alpha/2}$ (or respectively by $\cos\frac\alpha2 + j\sin\frac\alpha2 = e^{j\alpha/2}$ or $\cos\frac\alpha2 + k\sin\frac\alpha2 = e^{k\alpha/2}$). Moreover, the conjugate of a quaternion $q$ for the rotation $R$ is a quaternion $q^*$ for the inverse rotation $R^{-1},$ since $q^*q = qq^* = 1,$ which is a rotation by a zero angle (or if you would prefer a different explanation, because reversing the sign of the imaginary part, which is conjugation, is equivalent to reversing the sign of the angle $\theta$ in $q = \cos(\theta/2) + (\sin(\theta/2))\hat{\mathbf u}$).

Due to the way rotation by means of a quaternion is defined, the first rotation in a sequence is the rightmost factor in the product of rotation quaternions. So if we want to rotate the vector $k$ (the unit vector pointing upward along the $z$ axis) by an angle $\phi$ around the $y$-axis and then by an angle $\theta$ around the $z$-axis, the quaternion for this rotation is $p_{\theta,\phi} = e^{k\theta/2} e^{j\phi/2},$ its conjugate is $p_{\theta,\phi}^* = e^{-j\phi/2} e^{-k\theta/2},$ and the purely imaginary unit quaternion equivalent to the vector with spherical coordinates $(1, \theta, \phi)$ is $$ q_{\theta,\phi} = e^{k\theta/2} e^{j\phi/2} k e^{-j\phi/2} e^{-k\theta/2}. $$

It turns out the answer looks something like your initial guess, with some important distinctions: we use $i\theta/2$ and $i\phi/2$ as exponents instead of $i\theta$ and $i\phi,$ and in order to get the coordinates of the actual desired vector we must use these exponents to rotate the unit vector $k.$


For completeness, here's another way to derive the same answer. I decided to describe this method later because it requires much more calculation.

Any unit quaternion $ix + jy + kz,$ where $i,$ $j,$ and $k$ are the three imaginary units of the quaternion and $(x,y,z) \in \mathbb R^3,$ represents a $180$-degree rotation around the unit vector $(x,y,z).$ And if \begin{align} x &= \sin\phi \cos\theta, \\ y &= \sin\phi \sin\theta, \\ z &= \cos\phi, \end{align} then $(1, \theta, \phi)$ are spherical coordinates of the axis of rotation, and hence the quaternion corresponds almost uniquely to those coordinates. There is a complication, namely, the $180$ degree rotation around the axis is the same for the axis given by $(x,y,z)$ as for $(-x,-y,-z),$ and likewise the quaternions $q$ and $-q$ represent the same rotation; hence there is some ambiguity about whether a particular quaternion corresponds to particular spherical coordinates $(1, \theta, \phi)$ or to the coordinates $(1, \theta + \pi, \pi - \phi),$ that is, the antipodes of $(1, \theta, \phi).$

Setting aside that ambiguity for now, the question is just how to construct such a rotation. One way is to rotate the point at spherical coordinates $(1, \theta, \phi)$ to the positive $z$-axis, rotate by $\pi$ radians around the $z$-axis, then rotate the positive $z$-axis back to the spherical coordinates $(1, \theta, \phi).$ The rotations to do this are a rotation by $-\theta$ radians around the $z$-axis, which brings the desired rotation axis into the $x,z$ plane, followed by a rotation by $-\phi$ radians around the $y$-axis to bring the axis onto the $z$-axis, followed by a rotation by $\pi$ radians around the $z$-axis, then $\phi$ radians around the $y$-axis and finally $\theta$ radians round the $z$-axis to bring the rotation axis back to its original location. This rotation described is represented by the quaternion $$ q_{\theta,\phi} = e^{k\theta/2} e^{j\phi/2} e^{k\pi/2} e^{-j\phi/2} e^{-k\theta/2}. $$

Working this out in detail, first note that $e^{k\pi/2} = \cos\frac\pi2 + k\sin\frac\pi2 = k$; then \begin{align} e^{j\phi/2} e^{k\pi/2} e^{-j\phi/2} &= \left(\cos\frac\phi2 + j\sin\frac\phi2\right) k \left(\cos\frac\phi2 - j\sin\frac\phi2\right) \\ &= k \cos^2\frac\phi2 + jk \sin\frac\phi2\cos\frac\phi2 - kj \cos\frac\phi2\sin\frac\phi2 - jkj \sin^2\frac\phi2 \\ &= k \left(\cos^2\frac\phi2 - \sin^2\frac\phi2\right) + 2i \sin\frac\phi2\cos\frac\phi2 \\ &= k \cos\phi + i \sin\phi \\ \end{align} and so \begin{align} q_{\theta,\phi} &= e^{k\theta/2} (k \cos\phi + i \sin\phi) e^{-k\theta/2} \\ &= \left(\cos\frac\theta2 + k\sin\frac\theta2\right) (k \cos\phi + i \sin\phi) \left(\cos\frac\theta2 - k\sin\frac\theta2\right) \\ &= \left(k \cos^2\frac\theta2 + k^2\sin\frac\theta2\cos\frac\theta2 - k^2\sin\frac\theta2\cos\frac\theta2 - k^3 \sin^2\frac\theta2\right)\cos\phi \\ &\qquad + \left(i \cos^2\frac\theta2 + ki \sin\frac\theta2\cos\frac\theta2 - ik \cos\frac\theta2\sin\frac\theta2 - kik \sin^2\frac\theta2\right)\sin\phi \\ &= k \left(\cos^2\frac\theta2 + \sin^2\frac\theta2\right)\cos\phi + i \left(\cos^2\frac\theta2 - \sin^2\frac\theta2\right)\sin\phi + 2j \sin\frac\theta2\cos\frac\theta2\sin\phi \\ &= i \cos\theta\sin\phi + j \sin\theta\sin\phi + k \cos\phi,\\ \end{align} which is exactly what we want for the unit vector with spherical coordinates $(1, \theta, \phi).$

Related Question