Geodesic of quaternion swings vs vector angle

52 Views Asked by At

Context

I work on calculating distance between quaternions, the idea at the end is to train a machine learning algorithm to estimate a rotation in quaternion.

I have two quaternions $Q_1$ and $Q_2$ that rotate the same vector $v = [0, 1, 0]^\intercal$.

If I rotate $v$ with $Q_1$ and $Q_2$ I obtain respectively $w_1 = Q_1VQ_1^{-1}$ and $w_2 = Q_2VQ_2^{-1}$ where $V$ is the pure imaginary quaternion formed with $v$ as its imaginary part.

The problem is that, for now, I only have $w_2$ to estimate $Q_2$ (this will change in the future and I want to stay in quaternion as much as possible). I estimate $Q_2$ as in this solution as the shortest arc rotation from $v$ to $w2$. I know, that this solution for $Q_2$ is not unique.

Still, I want to measure distance between $Q_1$ and $Q_2$ and I figured two ways to compute angles between $Q_1$ and $Q_2$ the vector angle and the quaternion geodesic distance.

Vector angle

I compute this angle with normalized $w_1$ and $w_2$ as $d_{vec}(w_1, w_2) = cos^{-1}(w_1 \cdot w_2)$

Geodesic distance

Since, I'm aware that the solution of $Q_2$ from $w_2$ is not unique I use the swing representation of $Q_2$ and $Q_1$ and compute the geodesic distance as:

$d_{quat}(Swing(Q_1, v), Swing(Q_2, v)) = cos^{-1}(2 \langle Swing(Q_1, v), Swing(Q_2,v) \rangle ^2 - 1)$

with the swing computed as in second page of the article of Dobrowolski:

$Swing(Q, v) = cos(\alpha / 2) + sin(\alpha / 2) (n_x \mathbf{i} + n_y \mathbf{j} + n_z \mathbf{k})$

where $n$ is the normalized crossproduct between $v$ and $w$, and $\alpha$ is obtained with $\alpha = cos^{-1}(v \cdot w)$

Question

I thought both measure of distance would be similar since I calculate the geodesic of the swing quaternion only but I have not the same results when I compute it.

Example

I have $Q_1 = 0.10705747 + 0.98402538 i + 0.10583675 j + 0.09503334 k$ and $w_2 = [0.23794916, -0.94679614, -0.21669625]^\intercal$.

Then I'm able to compute:

  • $w_1 = [ 0.18794403, -0.95467456, 0.23081057]^\intercal$
  • $Q_2 = 0.16310098 -0.66430089 i + 0. j -0.72945349 k$
  • $Swing(Q_1, v) = 0.150541417 + 0.766601564 i + 0. j -0.624226981 k$
  • $Swing(Q_2, v) = 0.16310098 -0.66430089 i + 0. j -0.72945349 k = Q_2$

And then I obtain as distance:

  • $d_{vec}(w_1, w_2) = 0.45425647935625296$
  • $d_{quat}(Swing(Q_1, v), Swing(Q_2, v)) = 3.0828720104974527$

The distances in this example are really different. Especially, the geodesic $d_{quat}(Q_1, Q_2)$ is almost at $\pi$ even if the quaternions and vectors are not that different at first glance.

Is my reasoning false or is it my way of calculating it? I can't grasp why the two distances calculated can be that different, especially with the use of the swing. Also, for other cases both distances are close.