right now i am working on a computer vision project and will recognize fiducial markers, i created a simulation testbed for benchmarking the precision of different methods. E.g. i do rotate the markers and later try to get the rotation (orientation) of the marker from the captured images.

The marker is always rotated around the z-axis, with following euler-angles:

$r_{gt} = [\alpha_0, \beta_0, \gamma_0]$

let say we have recognized the amrker in the image with following orientation to the world corrdinate (both orienations were measured w.r.t. world coordinate)

$r_{i} = [\alpha_i, \beta_i, \gamma_i]$

$d(r_0, r_i) = ? $

Now my quastion is how can i measure the distance between the two rotations? i already did check out this link Quaternion distance.

Plz if you give an answer also give the referrence link, where i can investigate about this topic!

  • $\begingroup$ What exactly do you mean by "the distance between rotations"? There are many natural metrics on the set of rotations. For example, the group $SO(3)$ has a constant curvature $1$ metric. Do you use that distance? Or scale it somehow? Or maybe you measure distance by the action on the sphere in $\mathbb{R}^3$, something like $d(r_0,r_1) = max_{x\in S^2} \{d(r_0(x), r_1(x))\}$? (I haven't checked if this last proposal satisfies the triangle inequality....) $\endgroup$ – Jason DeVito Dec 6 '18 at 14:18
  • $\begingroup$ What i mean is how far the both rotation vectors are from each other? in the normal cartesian space we can measure the distance btw. two vectors easily, but how do we handle the rotation vectors? $\endgroup$ – arash javan Dec 6 '18 at 14:40
  • $\begingroup$ One possibility is simply to measure the angle difference for each component. If you want an unique measure, a possibility is to consider the two normal matrices associated to each set of angles, and to measure the distance between these normal matrices $\endgroup$ – Damien Dec 6 '18 at 15:48

Euler angles are not good for computing metrics as they have no proper symmetries. I suggest (since the question is tagged under quaternions) you convert your two orientations to quaternions $p$ and $q$. Then:

First, assuming by distance you mean how far apart are two rotations.

Second, knowing that quaternions have a double cover of the rotation manifold, that is, $q$ and $-q$ represent the same rotation.

Third, from second, say that the 'distance' from any quaternion $q=(w,x,y,z)$ to the identity quaternion $(1,0,0,0)$ makes sense if $w>0$. Otherwise, for $w<0$, the distance should be computed to the 'other' identity $(-1,0,0,0)$, which is indeed closer; or equivalently, one would find the distance between $-q$ and the true identity $(1,0,0,0)$.

Fourth, the distance between two quaternions $p$ and $q$ can be found as follows:

  1. take $r = p^* q$ the quaternion that joins $p$ to $q$. The distance from $p$ to $q$ is now equal to the distance from $r$ to $(1,0,0,0)$ (or to $(-1,0,0,0)$, see Third above).
  2. take the log, $u\theta = \log(p^* q)$, where $u=[u_x,u_y,u_z]$ is a unit vector defining the axis of rotation, and $\theta$ is half the rotated angle.
  3. the distance is the rotated angle, $\phi=2\theta$.

Note: having unit quaternions $q=[\cos(\phi/2), u_x \sin(\phi/2), u_y \sin(\phi/2), u_z \sin(\phi/2)]$, the log can be found by inspection, but if only the distance is sought, this distance $\phi$ can be found by just:

  1. $r = p^* q$ as in 1. above
  2. if $r_w<0$ do $r \gets -r$ (change sign of the quaternion $r$).
  3. $\phi=2 \arccos(r_w)$, where $r_w$ is the real part of $r$.

Fifth. You can use a shortcut by considering just double the angle between the two quaternions seen as 4'vectors, ie, $$ \cos \theta = p^\top q \rightarrow \phi = 2\theta = 2\arccos (p^\top q) $$ If $\cos\theta<0$, change the sign of one of the quaternions and start over.

All this info can be found here https://arxiv.org/abs/1711.02508


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.