# Problem

Quaternions $$X$$, $$Y$$, which represents 3-dimensional points are given. Quaternion $$q$$ is what is to be solved.

I want to know unknown rotation between $$X$$ and $$Y$$. In other words, I want to find $$q$$ in the following equation.

$$Y = q * X * \overline{q}$$

$$\overline{q}$$ means conjugate quaternion of $$q$$. Real parts of $$X$$, $$Y$$ are always zero.

How can I find $$q$$ mathematically?

• I assume $X$ and $Y$ represent rotations instead of positions? Also should $q$ represent the rotation between $X$ and $Y$, because then it doesn't make sense to also multiply with $\bar{q}$? Mar 18 '20 at 18:41
• Or are $X$ and $Y$ quaternions with only vector part? Mar 18 '20 at 18:42
• @fibonatic $X$ and $Y$ represents pure quaternion, which has only vector(imaginary) part. Thanks for you comments.
– Shin
Mar 20 '20 at 11:13

Your question is related to Wahba's problem, which initially is defined for rotation matrices but can also be defined for unit quaternions and can be solved with Davenport's q-method. However, in order to have a uniquely defined rotation it is required to have at least two pairs of vectors.

You only have one pair of vectors. The second pair could be chosen as the rotation axis, which should remain unchanged during the rotation. For this rotation axis you can choose any unit vector which is equidistant to both vectors of the first pair. When denoting the vector/imaginary parts normalized to unit length of $$X$$ and $$Y$$ as $$x$$ and $$y$$ respectively then the rotation axis $$r$$ can be parameterized using

\begin{align} n &= \frac{x \times y}{\|x \times y\|}, \\ m &= \frac{x + y}{\|x + y\|}, \\ r &= \cos(\phi)\,n + \sin(\phi)\,m. \end{align}

The smallest and largest resulting rotation (in terms of rotation angle) are obtained using $$\phi=0$$ and $$\phi=\pi/2$$ respectively, with $$n$$ and $$m$$ as axis of rotation respectively. The corresponding unit quaternions are

$$q = \begin{bmatrix} m\cdot x \\ \|x \times m\|\,n\end{bmatrix}, \quad q = \begin{bmatrix} 0 \\ m\end{bmatrix},$$

respectively. It can be noted that this method will fail if $$x$$ and $$y$$ are linear dependent (i.e. $$y = \pm x$$). When $$y = x$$ then any rotation with $$x$$ as rotation axis would suffice, so $$q = \begin{bmatrix}\cos(\theta) & \sin(\theta)\,x^\top\end{bmatrix}^\top$$. When $$y = -x$$ then any rotation of $$\pi$$ radians around any axis $$t$$, which is perpendicular to $$x$$, would suffice, so $$q = \begin{bmatrix}0 & t^\top\end{bmatrix}^\top$$.

• Thanks for the answer! The answer was a little more difficult than I expected, but I understand that this is similar problem to procrutes method and that's reasonable. I appreciate your advice.
– Shin
Mar 22 '20 at 2:35