3

This problem has already been covered over here and also here. But I have some confusion with the answers there since they state that the axis of rotation is precisely the cross product of the two (normalized) vectors. That is,

$$\hat{q}=\hat{a} \times \hat{b}$$

But isn't this only true when both $\hat{a}$ and $\hat{b}$ are orthogonal to $\hat{q}$? Since the cross product of the two vectors isn't parallel to the axis of rotation when $\hat{a}$ and $\hat{b}$ are not orthogonal, i.e.,

$$\hat{a}\times\hat{b} = (\alpha\hat{q}+\overrightarrow{m})\times(\beta\hat{q}+\overrightarrow{n}) = \overrightarrow{p} + \gamma\hat{q}$$

where $\overrightarrow{m}$ and $\overrightarrow{n}$ are orthogonal to $\hat{q}$ and $\overrightarrow{p}$ is some vector not parallel to $\hat{q}$.

So how can we take the axis of rotation ($\hat{q}$) to be the cross product? I might just be horribly mistaken by I cannot figure out where I am going wrong.

  • 2
    The cross product is always parallel to the axis of rotation. – user192234 Jun 26 '25 at 05:15
  • @user192234 But after distributing under the vector multiplication, I get vectors that aren't orthogonal to q. – Amrit Sanjeev Jun 26 '25 at 05:17
  • There are infinitely many rotations taking $\hat a$ to $\hat b$. Most have $\hat q \ne \hat a\times\hat b$, but at most two of them have $\hat q=\pm\hat a\times\hat b$. If we're just given $\hat a$ and $\hat b$ and want some rotation that takes one to the other, then it's most natural to choose $\hat q=\hat a\times\hat b$. – Nicholas Todoroff Jun 26 '25 at 05:18
  • @NicholasTodoroff Could you elaborate on the infinitely many axes of rotation. I would imagine there would only be one axis which is perpendicular to the plane of rotation. – Amrit Sanjeev Jun 26 '25 at 05:32
  • 1
    The cross product $a\times b$ is always orthogonal to both $a$ and $b.$ – Thomas Andrews Jun 26 '25 at 06:37
  • You can compose a rotation sending $a$ to $b$ with any rotation through the axis $b.$ That gives you infinitely many rotations. @AmritSanjeev – Thomas Andrews Jun 26 '25 at 06:40

2 Answers2

6

Three Cases. Given 3D unit vectors $\bf a$ and $\bf b$, the rotations which send ${\bf a}\mapsto{\bf b}$ are described in $3$ cases. The first $2$ are trivial. I'll borrow a physics term for the $2$nd.

  • parallel vectors (${\bf a}={\bf b}$):$~~$ any angle around the axis ${\bf a}$
  • antiparallel vectors (${\bf b}=-{\bf a}$):$~~$ any $180^\circ$ angle around any axis perpendicular to ${\bf a}$
  • generic vectors (${\bf a}\ne\pm{\bf b}$):$~~$ any axis in the span of ${\bf a}$, ${\bf b}$'s normal ${\bf n}$ and midpoint ${\bf m}$, by the appropriate angle; for axes ${\bf n}$ and ${\bf m}$ specifically, angles $\angle{\bf ab}$ and $180^\circ$ respectively.

Two Extremes. Let's look at the generic case's most salient examples in more detail.

  • quaternion $q_1={\bf m}$: Rotation around the midpoint ${\bf m}=\frac{{\bf a}+{\bf b}}{\|{\bf a}+{\bf b}\|}$ by $180^\circ$.
  • quaternion $q_2=\exp(\frac{\theta}{2}{\bf n})$: Rotation by the convex angle $\theta=\angle{\bf ab}$ around the axis ${\bf n}$, positively-directed from ${\bf a}$ to ${\bf b}$ in their oriented span with unit normal ${\bf n}=\frac{{\bf a}\times{\bf b}}{\|{\bf a}\times{\bf b}\|}$.

Note $q_1$ has the polar form $q_1=\exp(\frac{\pi}{2}{\bf m})$, which is just $\bf m$. Since $1,{\bf m},{\bf n}$ are orthogonal in $\Bbb H$, we can say $q_1,q_2$ are orthogonal in $\Bbb H$ too.

Minimal Rotation. The unique rotation around ${\bf n}$ corresponds to the antipodal pair of quaternions $\pm\exp(\frac{\theta}{2}{\bf n})$. From the "spinorial" perspective, $-q_2$ rotates around $-{\bf n}$ by $-\theta$, or equivalently around $\bf n$ by the reflex angle $2\pi-\theta$. We can rewrite $q_2$ in terms of $\bf a$, $\bf b$ via Euler's Formula, half-angle formulas, and dot product formula:

$$ \begin{array}{ccl} q_2 & = & \exp\bigl(\frac{\theta}{2}{\bf n}\bigr) ~=~ \cos\bigl(\frac{\theta}{2}\bigr)+\sin\bigl(\frac{\theta}{2}\bigr)\,{\bf n} \\[3pt] & = & \sqrt{\frac{1+\cos\theta}{2}}+\sqrt{\frac{1-\cos\theta}{2}}\,{\bf n} \\[3pt] & = & \sqrt{\frac{1+{\bf a}\cdot{\bf b}}{2}}+\sqrt{\frac{1-{\bf a}\cdot{\bf b}}{2}}\frac{{\bf a}\times{\bf b}}{\|{\bf a}\times{\bf b}\|}. \end{array} $$

Often $q_2$ is the rotation chosen to map ${\bf a}\mapsto{\bf b}$ since it has the smallest angle. (Presumably there are computational and graphical reasons as well, but I'm not a programmer.)

All Rotations. What about the set ${\cal T}({\bf a},{\bf b})$ of all rotations which map ${\bf a}\mapsto{\bf b}$? It corresponds to a circle of unit vectors in $\Bbb H$ which lie in a 2D subspace $\cal S$. Rewrite $q{\bf a}q^{-1}={\bf b}$ as $q{\bf a}={\bf b}q$ so as to allow non-unit quaternions. Thus, the solution space $\cal S$ is (in linear algebra terms) the kernel of the linear operator $q\mapsto q{\bf a}-{\bf b}q$. It is not too hard to verify the image of $q=1$ and $q={\bf a}$ under this linear operator are linearly independent in $\Bbb H$, so the image has dimension at least $2$, and thus the kernel has dimension at most $2$. We know $q_1={\bf m}$, $q_2=\exp(\frac{\theta}{2}{\bf n})$ are in the kernel, so every other solution is a linear combination of $q_1$ and $q_2$.

So, ${\cal T}({\bf a},{\bf b})$ is the unit circle in ${\cal S}={\rm span}\{q_1,q_2\}\subset\Bbb H$, i.e. every rotation which sends ${\bf a}\mapsto{\bf b}$ is a normalized linear combination of $q_1$ and $q_2$.

Visualization. Every rotation is part of a "one-parameter subgroup," which in 3D basically means all rotations around a given axis. The arc swept from $\bf a$ to $\bf b$ under such rotations is part of a circle on the sphere $S^2$. For $q_1$, this circle has minimum spherical radius $\frac{\theta}{2}$ and center $\bf m$. For $q_2$ it has maximum spherical radius $\frac{\pi}{2}$ (the unique great circle thru $\bf a$ and $\bf b$) and center $\bf n$.

As we let the rotation vary, we get different circles. This results in a foliation of the sphere, consisting of all circles thru $\bf a$ and $\bf b$. It is the spherical analogue of the pencil of Apollonian circles in the plane $-$ in fact they are related by stereographic projection. (On the Riemann sphere, these are flowlines of hyperbolic Mobius transformations with fixed points $\bf a$, $\bf b$.) The set of all the circles' centers is the perpendicular bisector of the arc from $\bf a$ to $\bf b$.

Transporters. In the language of group actions, if $G$ acts on $\Omega$ and $a,b\in\Omega$ then the set $T(a,b)=\{g\in G\mid ga=b\}$ of all group elements sending $a\mapsto b$ is called the transporter. It is a left and right coset $T(a,b)=g\,{\rm Stab}(a)={\rm Stab}(b)g$ for any representative $g\in T(a,b)$.

For us, $G={\rm SO}(3)$ and $\Omega=S^2$, then ${\rm Stab}({\bf a})$ and ${\rm Stab}({\bf b})$ are the unit circles of $\Bbb R[{\bf a}]$ and $\Bbb R[{\bf b}]$ respectively (both of these 2D subalgebras are $\cong\Bbb C$ by corresponding $\bf a$ or $\bf b$ to $\bf i$). What the coset equation says, then, is that any rotation sending ${\bf a}\mapsto{\bf b}$ can be precomposed with a rotation around $\bf a$ or postcomposed with a rotation around $\bf b$ and the result is still a rotation which sends ${\bf a}\mapsto{\bf b}$ (one of Thomas Andrews' comments under the OP).


Quaternions. For me, the quaternions are a 4D algebra $\Bbb H=\Bbb R\oplus\Bbb R^3$ and every quaternion is uniquely expressible as a sum of a scalar and a 3D vector. The product of vectors satisfies the "geometric product" formula ${\bf uv}=-{\bf u}\cdot{\bf v}+{\bf u}\times{\bf v}$, and thus the product of quaternions can be FOILed. Sqrts of $+1$ are $\pm1$, sqrts of $-1$ are unit vectors of $S^2\subset\Bbb R^3$, quaternions commute iff they have parallel vector parts, and anticommute iff are orthogonal vectors. It has orthonormal basis $\{1,{\bf i},{\bf j},{\bf k}\}$ with inner product $\langle p,q\rangle={\rm Re}(\overline{p}q)$ (where real part means same as scalar part, and $\overline{p}$ is the quaternion conjugate).

$\bigl[$ While $\Bbb H$ is generated by ${\bf i},{\bf j}$ and thus is the geometric algebra ${\cal G}(0,2)$ (aka Clifford algebra), its 3D symmetry indicates it's better (in the geometric algebra context) to think of it as the even subalgebra of either of ${\cal G}(3,0)$ or ${\cal G}(0,3)$. Symmetry is implicit in Hamilton's Broom Bridge equations ${\bf i}^2={\bf j}^2={\bf k}^2={\bf ijk}=-1$, and the cycle rule for multiplying ${\bf i},{\bf j},{\bf k}$, leading to the dot/cross product description I gave above with 3D symmetry. The vector algebra wars and history of quaternions, vectors (electromagnetism), and geometric algebra is fascinating, see M. Crowe's A History of Vector Analysis. $\bigr]$

coiso
  • 4,721
1

Inasmuch as the question as posed seems to be more about vector algebra and geometry than about quaternions, here's an answer focusing on the former.

Descriptive

[other answers] state that the axis of rotation is precisely the cross product of the two (normalized) vectors. That is,

$$ \hat{q} = \hat{a} \times \hat{b} $$

That's a simplification. Supposing that $a$ and $b$ are not (anti-)parallel, the cross product gives the direction of one possible axis of rotation. In particular, it gives the one associated with the smallest rotation angle. There is not a unique the rotation axis.

But isn't this only true when both $\hat{a}$ and $\hat{b}$ are orthogonal to $\hat{q}$?

Sort of. The cross product approach does assume that $a$ and $b$ are not (anti-)parallel, but subject to that proviso, their cross product is always the axis of a rotation that relates $\hat{a}$ to $\hat{b}$. But this is not the only such axis.

the cross product of the two vectors isn't parallel to the axis of rotation when $\hat{a}$ and $\hat{b}$ are not orthogonal, i.e.,

$$\hat{a}\times\hat{b}=(α\hat{q}+\overrightarrow{m})\times(β\hat{q}+\overrightarrow{n})=\overrightarrow{p}+γ\hat{q}$$

where $\overrightarrow{m}$ and $\overrightarrow{n}$ are orthogonal to $\hat{q}$ and $\hat{p}$ is some vector not parallel to $\hat{q}$.

There is no the axis of rotation. I guess you're trying to say that if $\hat{a}$ and(/or) $\hat{b}$ are not perpendicular to $\hat{q}$ then their cross product is not equal to $\hat{q}$. This is not controversial. You don't need to persuade us. But if this seems inconsistent to you then I take that to be because you are assuming, incorrectly, that there is a unique rotation axis for each $(\hat{a}, \hat{b})$ pair of unit vectors. NO, that is not the case.

On the contrary, there are infinitely many rotations around distinct axes that relate each such pair. At least one of them has an axis perpendicular to both $\hat{a}$ and $\hat{b}$. If these are not (anti-)parallel then exactly one rotation with that property relates them (though it can be parameterized in multiple ways), and its axis can be computed as $\hat{q}=\hat{a}\times\hat{b}$.

Constructive

Alternatively, observe that if we rotate $\overrightarrow{a}$ by some angle about a rotation axis described by $\overrightarrow{r}$, then the image, $R(\overrightarrow{a})$, must make the same angle with $\overrightarrow{r}$ that $\overrightarrow{a}$ does. Therefore, if $R(\hat{a})=\hat{b}$ and $\hat{a}\not\parallel\hat{b}$ then it follows that $\overrightarrow{r}$ is in the plane that perpendicularly bisects the angle between $\hat{a}$ and $\hat{b}$, which is, we can determine independently, the one that contains both the aforementioned rotation axes, $\hat{a}\times\hat{b}$ and $\hat{a}+\hat{b}$ (the latter not generally being a unit vector, but this does not matter).

Furthermore, if we choose any vector $\overrightarrow{v}$ in this plane and compute the angle $\rho$ between the (any) plane defined by $\overrightarrow{v}$ and $\overrightarrow{a}$ and the (any) plane defined by $\overrightarrow{v}$ and $\overrightarrow{b}$, then a rotation of magnitude (one of) $\rho$ or $-\rho$ around $\overrightarrow{v}$ takes $\hat{a}$ to $\hat{b}$. That is, every nonzero vector in this plane, $m(\hat{a}+\hat{b}) + n(\hat{a}\times\hat{b})$, is the direction of the axis of a rotation taking $\hat{a}$ to $\hat{b}$, and there are no such rotations around any other vectors.

Geometric visualization

You can visualize this in terms of the unit sphere $U$. Consider a circle $C$ that lies on the surface of $U$ and contains $U \cap \overrightarrow{a}$. This doesn't need to be a great circle. Now consider a vector $\overrightarrow{v_C}$ perpendicular to $C$ and passing through its center. $\overrightarrow{v_C}$ will also pass through the center of $U$. Satisfy yourself that $C$ can be generated by rotations of $\hat{a}$ around $\overrightarrow{v_C}$. Now notice that for any two unit vectors $\hat{a}$ and $\hat{b}$, even (anti-)parallel ones, there is an infinite number of distinct circles on the surface of the unit sphere that contain both $U \cap \hat{a}$ and $U \cap \hat{b}$. For each such circle there is a corresponding rotation axis as already described. Because rotations of $\hat{a}$ around that axis generate the circle, which includes $\hat{b}$, each such circle corresponds to a distinct rotation that takes $\hat{a}$ to $\hat{b}$.

Summary

So how can we take the axis of rotation [...] to be the cross product?

Supposing that the cross product is nonzero, it is always the direction of a suitable rotation. It turns out to be a convenient choice, but it is not the only choice.