# Angular Distance Between Quaternions

I spent the past couple days reading about Quaternions on various resources and there are just a couple questions that I still do not fully understand, could someone please help me out?

Also, if you find my questions ill posed and believe that I have some deeper misunderstanding, it would be great if you could point me to some resource where I can clear my confusion.

Thanks!

1. When representing 2D rotations using complex numbers, we can apply a rotation to an arbitrary vector using the dot product operation. Why does the dot product not work for quaternions as well (and instead we need the Hamilton product $$qvq^{-1}$$ to apply the 3D rotation represented by $$q$$ to a vector $$v$$)?

1. When representing two different 3D rotations $$r_1$$ and $$r_2$$ using quaternions $$q_1$$ and $$q_2$$, one can use the geodesic distance between the two quaternions as a measure of how far apart from each other (different) are those rotations:

$$\alpha=arccos(2*^2 -1).$$

$$\alpha$$ is the value of the angular arc between the two quaternions in $$R^4$$ and varies between 0 and 180, and takes into account the fact that two quaternions are the same if the axis and angle are both negated.

• when $$\alpha=0$$ then $$r_1$$ and $$r_2$$ are the same, but when $$\alpha=180$$ what is the relation between $$r_1$$ and $$r_2$$? Are they the inverse of one another?
• I would have hoped that for an arbitrary vector $$v$$, $$\alpha$$ represented the angular distance between the rotated vector when rotating using $$q_1$$ and $$q_2$$, but that is not the case. Check the example below:

$$q_1 = (cos(\pi/4), sin(\pi/4) [1,0,0])$$ $$q_2 = (cos(\pi/4), sin(\pi/4) [-\frac{\sqrt(3)}{2},-1/2,0])$$

$$\alpha=arccos(2*^2 -1)=172.318$$

Now say I have a vector $$v_1=[1,2,3]$$ and apply the two rotations I get the two rotated vectors $$v_{11}=q_1 v_1 q_1^*=[1,-3,2]$$ and $$v_{12}=q_2 v_1 q_2^*=[1.3839,2.6650,-2.2320]$$ and if I measure the angle between these two vectors it actually is $$\beta_1 = arccos(\frac{}{||v_{11}||\cdot||v_{12}||})=142.287 \neq \alpha$$.

Furthermore, for a different vector $$v_2=[23,43,-15]$$ the final angle (omitting the calculations for brevity) is $$\beta_2=162.518$$, which is again different from $$\alpha$$ (and also $$\beta_1$$).

So what does $$\alpha$$ represent in term of points in the 3D space? I am having a hard time understanding how does closeness between quaternions translate to closeness in the 3D space.

• Re: 1 The product of two complex numbers doesn’t really correspond to a vector dot product. It’s really more akin to the product of two $2\times2$ matrices.
– amd
Commented Sep 3, 2019 at 1:44
• The geodesic distance given is just a particular instance of the geodesic distance in projective space $\mathbb{HP}^{d-1}$, namely for $d=1$. Also, the formula should really read $\text{acos}({2|\langle x,y\rangle|^2-1})$. If one quaternion is a unit multiple of the other, then the geodesic distance will be zero. If the two are not nearly equivalent than the geodesic distance will be larger. The 'angle' will be $\pi$ when the two points (or 'rotations') are as far away as possible.
– asd
Commented Sep 10, 2019 at 19:44

1. When representing 2D rotations using complex numbers, we can apply a rotation to an arbitrary vector using the dot product operation. Why does the dot product not work for quaternions as well (and instead we need the Hamilton product $$qvq^{-1}$$ to apply the 3D rotation represented by $$q$$ to a vector $$v$$)?

In 2D space, a vector $$v$$ can be rotated by "multiplying" it with a complex number "rotor" like $$R = \cos(\theta) + i \sin(\theta)$$, so that $$v' = R v$$, where $$v'$$ is the rotated vector. But the product involved is not the dot product, which would produces a real number, it is the complex number's product. That means, you really need to treat $$v$$ as a complex number.

Also notice that if you define your complex number rotor as $$R = \cos(\theta/2) + i \sin(\theta/2)$$ then you can rotate your vector using the sandwich product $$v' = R v R^{-1}$$. So it also works in 2D.

The fact that $$R v$$ doesn't work with quaternions is because the quaternion product is non-commutative. But there are some special cases in which quaternions allows the one-side product $$R v$$, such as when the rotation axis of $$R$$ is perpendicular to the vector $$v$$. So for instance if you define a quaternion like $$R = \cos(\theta) - (0,0,k) \sin(\theta)$$ which is a rotation around the $$k$$ axis and a pure quaternion $$v = 0 + (i, 0, 0)$$ which is in the $$ij$$ plane, then you can actually do $$v' = R v$$

$$R v = (\cos(\theta) - k \sin(\theta)) i$$ $$R v = i \cos(\theta) - k i \sin(\theta)$$ $$R v = i \cos(\theta) + j \sin(\theta)$$

Which is the usual formulae for rotation in a plane.

1. When representing two different 3D rotations $$r_1$$ and $$r_2$$ using quaternions $$q_1$$ and $$q_2$$, one can use the geodesic distance between the two quaternions as a measure of how far apart from each other (different) are those rotations:

$$\alpha=arccos(2*^2 -1).$$ ... So what does 𝛼 represent in term of points in the 3D space? I am having a hard time understanding how does closeness between quaternions translate to closeness in the 3D space.

An intuition about $$\alpha$$ can be built using the case when $$q_1$$ and $$q_2$$ do commute under the quaternion product i.e., $$q_1 q_2 = q_2 q_1$$. That is the case when the axis of rotation of $$q_1$$ and $$q_2$$ are the same.

So for instance $$q_1 = \cos(\theta_1/2) - b \sin(\theta_1/2)$$ and $$q_2 = \cos(\theta_2/2) - b \sin(\theta_2/2)$$.

The product $$q_1 q_2 = \cos((\theta_1 + \theta_2)/2) - b \sin((\theta_1 + \theta_2)/2)$$

The action of our new combined quaternion $$q_1 q_2$$ on a 3D vector $$v$$ of unit length laying in the plane that is orthogonal to axis $$b$$ (i.e. $$v \cdot b = 0$$) can be measured as a change in the angle:

$$\theta_1 + \theta_2 = \cos^{-1}(v \cdot ((q_1 q_2) v (q_1 q_2)^{-1}))$$

Note that in certain cases this might not be true. For instance if the sum of $$\theta_1 + \theta_2 = 2\pi$$ then $$v$$ doesn't change its orientation, so the net rotation angle would be zero.

Now, the product $$q_1 q_2^{-1}$$ is of our special interest because it measures the angle difference of the quaternions i.e., it allow us to compare them and tell whether they are close of far apart.

$$q_1 q_2^{-1} = \cos((\theta_1 - \theta_2)/2) - b \sin((\theta_1 - \theta_2)/2)$$

The action of that quaternion $$q_1 q_2^{-1}$$ on a 3D vector $$v$$ of unit length laying in the plane that is orthogonal to axis $$b$$ can be measured as a change in the angle:

$$\theta_1 - \theta_2 = \cos^{-1}(v \cdot ((q_1 q_2^{-1}) v (q_1 q_2^{-1})^{-1}))$$

That is very similar to the previous case, but now we are interested on measuring the angle difference i.e., the $$\alpha$$ that you compute, which would be equal to $$\theta_1 - \theta_2$$ in this example.

Now, things get complicated when $$q_1$$ and $$q_2$$ don't commute. If $$q_1$$ and $$q_2$$ don't commute then that means they have different axis of rotation. That is the most common case in 3D. In that case the product $$q_1 q_2^{-1}$$ produces a quaternion with a new axis of rotation that accounts for the total rotation, that axis is different from both $$q_1$$ and $$q_2$$ axis. The angle of rotation of $$q_1 q_2^{-1}$$ (i.e., the $$\alpha$$) is not the subtraction of angles of rotation of $$q_1$$ and $$q_2$$ but a new angle which combines both but about the new axis of rotation. Although, we still can compute that angle, which is the $$\alpha$$ that you have computed, but it doesn't corresponds to a measure that you usually take from 3D vectors (in general, you would need to project your 3D vectors to the rotation plane and measure the angle there).

The $$\alpha$$ that you are computing is a distance measure of how far apart are two quaternions, but it's not the angle of rotation between $$q_1 v q_1^{-1}$$ and $$q_2 v q_2^{-1}$$ as you wish. However, what is true in general is that "close" quaternions corresponds to "close" rotations. Although sometimes far apart quaternions e.g., with opposite sign, can lead to close rotations as well. So careful is needed w.r.t sign.

1. For unit quaternions $$Q=\{a+bi+cj+dk: a^2+b^2+c^2+d^2=1\}\approx S^3$$ and imaginary quaternions $$im\ H=\{ai+bj+ck:, a,b,c\in \Bbb{R}\}\approx\mathbb{R}^3$$ you have $$\forall_{q\in Q, v\in im\ H}\ \ qvq^{-1} \in im\ H,$$ however not necessarily $$\forall_{q\in Q, v\in im\ H}\ \ qv \in im\ H,$$ hence the $$v\rightarrow qvq^{-1}$$ approach.
• if $$\alpha=180$$ then $$q_1=-q_2$$ but not necessarily $$q_2^{-1} = q_1$$ as for quaternions $$h^{-1} = h^*/||h||^2$$, for $$(a+bi+cj+dk)^* = a-bi-cj-dk$$
• There exists "angular" characterization of $$Q$$ acting in $$im\ H$$. If $$q = \cos\alpha+l\sin\alpha,\quad l\in im\ H$$ then $$\phi(v) = qvq^{-1}$$ is rotation around axis $$l$$ of $$2\alpha$$ degrees. I believe this much more convenient than angular distance.