Defining a cost function to find a rotation












0












$begingroup$


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 $leftlangle v_i,w_i rightrangle = leftlVert v_i rightrVert leftlVert w_i rightrVert 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_iright) 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)$...)










share|cite|improve this question









$endgroup$

















    0












    $begingroup$


    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 $leftlangle v_i,w_i rightrangle = leftlVert v_i rightrVert leftlVert w_i rightrVert 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_iright) 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)$...)










    share|cite|improve this question









    $endgroup$















      0












      0








      0





      $begingroup$


      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 $leftlangle v_i,w_i rightrangle = leftlVert v_i rightrVert leftlVert w_i rightrVert 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_iright) 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)$...)










      share|cite|improve this question









      $endgroup$




      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 $leftlangle v_i,w_i rightrangle = leftlVert v_i rightrVert leftlVert w_i rightrVert 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_iright) 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)$...)







      calculus linear-algebra reference-request optimization






      share|cite|improve this question













      share|cite|improve this question











      share|cite|improve this question




      share|cite|improve this question










      asked Dec 4 '18 at 9:11









      user8469759user8469759

      1,5381618




      1,5381618






















          1 Answer
          1






          active

          oldest

          votes


















          1












          $begingroup$

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






          share|cite|improve this answer









          $endgroup$













          • $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|costheta_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





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "69"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          noCode: true, onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3025325%2fdefining-a-cost-function-to-find-a-rotation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1












          $begingroup$

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






          share|cite|improve this answer









          $endgroup$













          • $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|costheta_i$ so $Omega v_i cdot u_i=|v||u|cos(theta_i -theta_Omega)$
            $endgroup$
            – user622715
            Dec 4 '18 at 11:11


















          1












          $begingroup$

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






          share|cite|improve this answer









          $endgroup$













          • $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|costheta_i$ so $Omega v_i cdot u_i=|v||u|cos(theta_i -theta_Omega)$
            $endgroup$
            – user622715
            Dec 4 '18 at 11:11
















          1












          1








          1





          $begingroup$

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






          share|cite|improve this answer









          $endgroup$



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







          share|cite|improve this answer












          share|cite|improve this answer



          share|cite|improve this answer










          answered Dec 4 '18 at 9:34









          user622715user622715

          261




          261












          • $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|costheta_i$ so $Omega v_i cdot u_i=|v||u|cos(theta_i -theta_Omega)$
            $endgroup$
            – user622715
            Dec 4 '18 at 11:11




















          • $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|costheta_i$ so $Omega v_i cdot u_i=|v||u|cos(theta_i -theta_Omega)$
            $endgroup$
            – user622715
            Dec 4 '18 at 11:11


















          $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$
          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$
          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$
          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$
          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|costheta_i$ so $Omega v_i cdot u_i=|v||u|cos(theta_i -theta_Omega)$
          $endgroup$
          – user622715
          Dec 4 '18 at 11:11






          $begingroup$
          $v_i cdot u_i= |v||u|costheta_i$ so $Omega v_i cdot u_i=|v||u|cos(theta_i -theta_Omega)$
          $endgroup$
          – user622715
          Dec 4 '18 at 11:11




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Mathematics Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3025325%2fdefining-a-cost-function-to-find-a-rotation%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?