QMatrix4x4 multiply order



  • 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


  • Qt Champions 2016

    @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.



  • 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
    


  • QMatrix4x4 tmp = ...;
    tmp.translate(10,0,0);
    

    results in

    tmp = tmp * translationmatrix
    

    So the correct answer seams to be

    1. identity * projection * view

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.