Finding quaternion that transforms to particular basis I want to find a quaternion $x \in{\mathbb{H}} $ that transforms (rotates) the $ i,j,k $ basis to a particular basis. In equations:
$$ x i x^{-1} = a_1 $$ 
$$ x j x^{-1} = a_2 $$
$$ x k x^{-1} = a_3 $$
I know that all three of these equations have an infinite amount of solutions, but given that the basis $a_1,a_2,a_3$ is orthonormal there should be only two $x$ that will solve all of these equations,  i.e: if $x$ is a solution, the only other solution is $-x$, since the image under rotation is the same. I know it's possible to extract the eigenvector/eigenvalue of the matrix formed by the basis and use that to form the quaternion, but I am wondering if  there is some expression that directly solves this equation using quaternions.
 A: Given any three $a,b,c \in \mathbb{H}$ which can be parametrized by some $x \in \mathbb{H}$ as
$$\begin{cases}
x i x^{-1} &= a\\
x j x^{-1} &= b\\
x k x^{-1} &= c
\end{cases}$$
We have 
$$\begin{array}{lcl}
i^2 = -1 &\implies& a^2 = ( x i x^{-1})^2 = x i^2 x^{-1} = x(-1)x^{-1} = -1\\
ij  = k  &\implies& ab  = (x i x^{-1})(x j x^{-1}) = xijx^{-1} = xkx^{-1} = c
\end{array}$$
Other combinations of $a,b,c$ will satisfy similar identities. In short, $a,b,c$ together
satisfy the same set of algebraic identities satisfied by the canonical base $i,j,k$ of $\mathbb{H}$.
Now let $q = 1 - (ai + bj + ck)$. If $q \ne 0$, we will have
$$\begin{align}
a q &= a ( 1 - (ai + bj + ck) ) = a - a^2 i - ab j - ack\\
    &= a + i - c j + b k\\
    &= ( -ai + 1 - ck - bj) i\\
    &= q i
\end{align}$$
This leads to $q i q^{-1} = a$. By a similar argument, one can show $q j q^{-1} = b$ and $q k q^{-1} = c$. In short, whenever $q = 1 - (ai+bj+ck) \ne 0$, 
we can take $\displaystyle\;x = \frac{q}{|q|}\;$.
Please note that $q = 0$ if and only if $x$ corresponds to a $180^\circ$ rotation.
I don't know any simple way to derive $x$ in that case.
