Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMatrix4x4 multiply order
Qt 6.11 is out! See what's new in the release blog

QMatrix4x4 multiply order

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • QT-static-prgmQ Offline
    QT-static-prgmQ Offline
    QT-static-prgm
    wrote on last edited by
    #1

    Hi,

    I have a question about the QMatrix4x4 class.

    This example code:

    QMatrix4x4 test;
    test.perspective(...); // projection
    test.lookat(...); // view
    

    What kind of matrix is test at the end? is it something like that:
    identity * projection * view
    or is it like that:
    view * projection * identity

    kshegunovK 1 Reply Last reply
    0
    • QT-static-prgmQ QT-static-prgm

      Hi,

      I have a question about the QMatrix4x4 class.

      This example code:

      QMatrix4x4 test;
      test.perspective(...); // projection
      test.lookat(...); // view
      

      What kind of matrix is test at the end? is it something like that:
      identity * projection * view
      or is it like that:
      view * projection * identity

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by
      #2

      @QT-static-prgm said in QMatrix4x4 multiply order:

      Since matrices don't commute in the general case and operate on the right-hand term I'd say the latter.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by VRonin
        #3

        It's quite easy just to test it...
        run

        QMatrix4x4 test;
        test.perspective(...); // projection
        

        check what is in test.

        QMatrix4x4 test;
        test.lookat(...); // view
        

        check what is in test.
        pre and post multiply these two by hand (you can use wolframalpha) and compare it to the result you get in

        QMatrix4x4 test;
        test.perspective(...); // projection
        test.lookat(...); // view
        

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        0
        • QT-static-prgmQ Offline
          QT-static-prgmQ Offline
          QT-static-prgm
          wrote on last edited by
          #4
          QMatrix4x4 tmp = ...;
          tmp.translate(10,0,0);
          

          results in

          tmp = tmp * translationmatrix
          

          So the correct answer seams to be

          1. identity * projection * view
          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved