Inverting a 4x4 rotate and translation matrix

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I have two OpenCV cv::Mats that represent rotates and transforms of cameras facing forwards and backwards. The matrices represent where the camera points to in 3D space (excuse the very crude rounding):



cv::Mat rear2World = [[-1, -0.004 -0.01, 3.56],
[0.006, 0.58, -0.8, -6.9],
[0.01, -0.81, -0.59, 0.8],
[0, 0, 0, 1]];
cv::Mat front2World = [[1, 0.007, 0, 3.5],
[0.001, -0.25, 0.97, -2.4],
[0.008, -1, -0.25, 0.49],
[0, 0, 0, 1]];


So, according to my understanding, to get a transformation matrix for front2Rear, I should just do:



cv::Mat front2Rear = front2World * rear2World.inv();


However, I get a result like:



cv::Mat front2Rear = [[-1, 0.01, 0.003, 7.22],
[-0.01, -0.93, -0.36, -8.5],
[0, -0.36, 0.933, -2.76],
[0, 0, 0, 1]];


I was expecting to get the last column to be equal [0.06, -4.5, 0.31] or so, but I'm probably got some fundamental understanding wrong! Can someone point me in the right direction, please.







share|cite|improve this question























    up vote
    0
    down vote

    favorite












    I have two OpenCV cv::Mats that represent rotates and transforms of cameras facing forwards and backwards. The matrices represent where the camera points to in 3D space (excuse the very crude rounding):



    cv::Mat rear2World = [[-1, -0.004 -0.01, 3.56],
    [0.006, 0.58, -0.8, -6.9],
    [0.01, -0.81, -0.59, 0.8],
    [0, 0, 0, 1]];
    cv::Mat front2World = [[1, 0.007, 0, 3.5],
    [0.001, -0.25, 0.97, -2.4],
    [0.008, -1, -0.25, 0.49],
    [0, 0, 0, 1]];


    So, according to my understanding, to get a transformation matrix for front2Rear, I should just do:



    cv::Mat front2Rear = front2World * rear2World.inv();


    However, I get a result like:



    cv::Mat front2Rear = [[-1, 0.01, 0.003, 7.22],
    [-0.01, -0.93, -0.36, -8.5],
    [0, -0.36, 0.933, -2.76],
    [0, 0, 0, 1]];


    I was expecting to get the last column to be equal [0.06, -4.5, 0.31] or so, but I'm probably got some fundamental understanding wrong! Can someone point me in the right direction, please.







    share|cite|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have two OpenCV cv::Mats that represent rotates and transforms of cameras facing forwards and backwards. The matrices represent where the camera points to in 3D space (excuse the very crude rounding):



      cv::Mat rear2World = [[-1, -0.004 -0.01, 3.56],
      [0.006, 0.58, -0.8, -6.9],
      [0.01, -0.81, -0.59, 0.8],
      [0, 0, 0, 1]];
      cv::Mat front2World = [[1, 0.007, 0, 3.5],
      [0.001, -0.25, 0.97, -2.4],
      [0.008, -1, -0.25, 0.49],
      [0, 0, 0, 1]];


      So, according to my understanding, to get a transformation matrix for front2Rear, I should just do:



      cv::Mat front2Rear = front2World * rear2World.inv();


      However, I get a result like:



      cv::Mat front2Rear = [[-1, 0.01, 0.003, 7.22],
      [-0.01, -0.93, -0.36, -8.5],
      [0, -0.36, 0.933, -2.76],
      [0, 0, 0, 1]];


      I was expecting to get the last column to be equal [0.06, -4.5, 0.31] or so, but I'm probably got some fundamental understanding wrong! Can someone point me in the right direction, please.







      share|cite|improve this question











      I have two OpenCV cv::Mats that represent rotates and transforms of cameras facing forwards and backwards. The matrices represent where the camera points to in 3D space (excuse the very crude rounding):



      cv::Mat rear2World = [[-1, -0.004 -0.01, 3.56],
      [0.006, 0.58, -0.8, -6.9],
      [0.01, -0.81, -0.59, 0.8],
      [0, 0, 0, 1]];
      cv::Mat front2World = [[1, 0.007, 0, 3.5],
      [0.001, -0.25, 0.97, -2.4],
      [0.008, -1, -0.25, 0.49],
      [0, 0, 0, 1]];


      So, according to my understanding, to get a transformation matrix for front2Rear, I should just do:



      cv::Mat front2Rear = front2World * rear2World.inv();


      However, I get a result like:



      cv::Mat front2Rear = [[-1, 0.01, 0.003, 7.22],
      [-0.01, -0.93, -0.36, -8.5],
      [0, -0.36, 0.933, -2.76],
      [0, 0, 0, 1]];


      I was expecting to get the last column to be equal [0.06, -4.5, 0.31] or so, but I'm probably got some fundamental understanding wrong! Can someone point me in the right direction, please.









      share|cite|improve this question










      share|cite|improve this question




      share|cite|improve this question









      asked Jul 27 at 7:46









      Ken Y-N

      1013




      1013

























          active

          oldest

          votes











          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',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          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%2f2864154%2finverting-a-4x4-rotate-and-translation-matrix%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f2864154%2finverting-a-4x4-rotate-and-translation-matrix%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What is the equation of a 3D cone with generalised tilt?

          Color the edges and diagonals of a regular polygon

          Relationship between determinant of matrix and determinant of adjoint?