javascript - 4x4 matrix multiplication order -


I am using the following library:

However, the question I take the same steps in different ways:

  // example 1m = tdl.math.matrix4.identity (); Tdl.math.matrix4. RotateX (m, 90 * (Math.PI / 180)); Tdl.math.matrix4.translate (m, [10,20,30]); Console.log (m); // output below 1/2 example 2 I = tdl.math.matrix4.identity (); R = tdl.math.matrix4.rotationX (90 * (Math.PI / 180)); T = tdl.math.matrix4.translation ([10,20,30]); M = tdl.math.matrix4.mul (i, r); M = tdl.math.matrix4.mul (m, t); Console.log (m);  
  • translate it by 10x,
  • 20y P> However, the output is not the same, the output is 1:
      [1, 0, 0, 0, 0, 6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766 -17, 0, 10, -30, 20.0000 00000000004, 1]  

    Here the output is 2

      [1, 0, 0, 0, 0 , 6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766e-17, 0, 10, 20, 30, 1]  

    As a result, I am taking the same steps , Then why is the result different?

  • Because the matrix product is different because the matrix is ​​on the left. In other words

      matA * matB! = MatB * MatA  

    Try

      i = tdl.math.matrix4.Account (); R = tdl.math.matrix4.rotationX (90 * (Math.PI / 180)); T = tdl.math.matrix4.translation ([10,20,30]); M = tdl.math.matrix4.mul (r, i); M = tdl.math.matrix4.mul (T, M); Console.log (m); // output below  

    output

      [1, 0, 0, 0, 0, 6.123031769111886e-17, 1, 0, 0, - 1 , 6.123031769111886e-17, 0, 10, -30, 20.000000000000004, 1]  

    Comments

    Popular posts from this blog

    ios - How do I use CFArrayRef in Swift? -

    eclipse plugin - Run java code error: Workspace is closed -

    c - Error on building source code in VC 6 -