Given two quaternions $x$ and $y$ with $|x|=|y|$, their real part being zero (i.e. them being vectors) and knowing that $y$ resulted from a rotation of $x$ by unit quaternion $q$, i.e. $$ y = q x q^{-1}, $$ is it possible to solve for $q$ in terms of $x$ and $y$.

I tried several kinds of multiplying from the left and from the right with $q$s, but non-commutative equation solving is rather unfamiliar and I cannot get the $q$ separated from both, $x$ and $y$.

  • $\begingroup$ Think about the analogous situation in $\mathbb R^3$: is there a unique rotation that maps a vector $x$ onto another vector $y$ with the same norm? $\endgroup$ – amd Sep 8 '18 at 22:06
  • $\begingroup$ You mean I need to add that $|x|=|y|$ to get this working at all. Alright. $\endgroup$ – Harald Sep 8 '18 at 22:08
  • $\begingroup$ My main point is that there’s an infinite number of rotations that map $x$ onto $y$. $\endgroup$ – amd Sep 8 '18 at 22:09
  • $\begingroup$ I believe you also need $x$ and $y$ to be "pure" quaternions, meaning real part zero. Such things are also called "vectors." en.wikipedia.org/wiki/Quaternions_and_spatial_rotation $\endgroup$ – Will Jagy Sep 8 '18 at 22:09
  • $\begingroup$ @amd I can imagine two, along the short and along the long angle. Why infinite? $\endgroup$ – Harald Sep 8 '18 at 22:11

There is an infinite number of rotations that map a vector $\vec x$ onto another vector $\vec y$ with the same norm, one for every vector that lies on the angle bisector of $\vec x$ and $\vec y$. If we restrict them to the plane defined by $\vec x$ and $\vec y$, i.e., to an axis that’s perpendicular to both vectors, then in most cases there are only two possibilities, and we can always choose the one with rotation angle in the interval $[0,\pi]$.

It’s convenient for the following to represent quaternions as ordered pairs $(r,\vec v)$ of a real number $r$ and vector $\vec v$. The product of two quaternions is then $$(r_1,\vec v_1)(r_2,\vec v_2) = (r_1r_2-\vec v_1\cdot\vec v_2,r_1\vec v_2+r_2\vec v_1+\vec v_1\times\vec v_2).\tag 1$$ As you probably know, rotating the vector $\vec v$ through an angle of $\theta$ about the axis given by the unit vector $\vec u$ can be accomplished by conjugating the pure quaternion $\mathbf v = (0,\vec v)$ by $$\mathbf q = \left(\cos{\frac\theta2},\vec u\sin{\frac\theta2}\right).\tag 2$$ Now, for a pair of pure quaternions, the product (1) reduces to $$(0,\vec x)(0,\vec y) = (-\vec x\cdot\vec y,\vec x\times\vec y) = \|\vec x\|\|\vec y\|(-\cos\theta,\vec u\sin\theta),$$ where $\theta$ is the angle between $\vec x$ and $\vec y$ and $\vec u = {\vec x\times\vec y\over\|\vec x\|\|\vec y\|}$ is the unit vector in the direction of $\vec x\times\vec y$. Comparing this to (2), we can see that constructing an appropriate rotation quaternion $\mathbf q$ from $\vec x$ and $\vec y$ is reduced to constructing a pair of vectors in the plane of $\vec x$ and $\vec y$ such that the angle between them is $\theta/2$. Taking $\vec x$ or $\vec y$ and their angle bisector $\vec x+\vec y$ will do the trick, resulting in $$\mathbf q = -\left(0,{\vec x+\vec y \over \|\vec x+\vec y\|}\right)\left(0,{\vec x \over \|\vec x\|}\right).$$ Note that this method fails when $\vec x=-\vec y$. In this case, $\mathbf q=(0,\vec u)$, where $\vec u$ is any unit vector orthogonal to $\vec x$.

  • $\begingroup$ Many thanks for the details. If I am not messing up, it turns out to be: if $\vec s= \vec x+ \vec y$ and for any vector $\vec v$ we say $\vec{v}_e = \vec v/\|\vec v\|$ then $q$ would be just $q=(\vec x_e\cdot \vec s_e, \vec x_e \times \vec s_e)$. Nice. $\endgroup$ – Harald Sep 9 '18 at 15:36
  • $\begingroup$ @Harald Looks right to me. I should’ve taken the computation that one extra step myself. It’s even easier to remember. $\endgroup$ – amd Sep 10 '18 at 1:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.