Suppose I have pairs of vector $\left\{(v_i,w_i)\right\}_{1 \leq i \leq n}$, and I want to find an angle $\theta$ that describes an optimal rotation that aligns all the pairs.

Now two possible cost functions came to my mind the first one is

$$ C_1(\theta) = \frac{1}{2n} \sum_i (\theta - \theta_i)^2 $$

where $\theta_i$ is the angle between $v_i$ and $w_i$. On the other end however since $\left\langle v_i,w_i \right\rangle = \left\lVert v_i \right\rVert \left\lVert w_i \right\rVert \cos \theta_i$

Clearly the two vectors are aligned if $\cos \theta_i = 1$ therefore I was thinking of minimizing

$$ C_2(\theta) = \frac{1}{2n} \sum_i \left(1 - \cos \left( \theta -\theta_i\right) \right)^2 $$

For both functions I'd assume all the angles, including the unknown are in the interval $[-\pi,\pi]$.

It is clear that if there's a perfect rigid transformations the solution would be the same for both cases, however in general which one is better?

Is there a known similar problem that uses $C_2$ instead of something like $C_1$?

Computationally speaking $C_1$ has a closed form solution

(Assume you have many many pairs $(v_i,w_i)$...)


$C_1$ has a closed form if you know the angles $\theta_i$ ,your vectors are in $2d$and don't have issues with $2\pi$ type ambiguities. As for C_$2$ which is more standard, try this

  • $\begingroup$ Interesting, how is my $C_2$ related to the wikipage? I don't see the same formula, is there a specific one you can point out just for sake of comparison? $\endgroup$ – user8469759 Dec 4 '18 at 9:39
  • $\begingroup$ By the way, in theory in my case $\theta_i$'s are known in my problem, I can easily retrieve them. $\endgroup$ – user8469759 Dec 4 '18 at 9:44
  • $\begingroup$ treat the vectors $v_i$ as the columns of $A$ and $u_i$ as the columns of$B$ ( as used in the wiki article). Applying a single rotation matrix $\Omega$ on the $v$'s now becomes $\Omega \{ v_1,\cdots v_n\}=\Omega A$ and the square of all the distances $\sum |\Omega v_i-u_i|^2$ is $|\Omega A-B|^2$ $\endgroup$ – user622715 Dec 4 '18 at 9:55
  • $\begingroup$ Though I understand the formula, I struggle a bit to see the resemblance with mine, am I supposed to be able to derive my $C_2$ from $\sum |\Omega v_i - u_i|^2$? $\endgroup$ – user8469759 Dec 4 '18 at 10:24
  • $\begingroup$ $v_i \cdot u_i= |v||u|\cos\theta_i$ so $\Omega v_i \cdot u_i=|v||u|\cos(\theta_i -\theta_\Omega)$ $\endgroup$ – user622715 Dec 4 '18 at 11:11

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.