I"m using the following library:
https://github.com/greggman/tdl/blob/master/tdl/math.js
however, the question is about different results i'm getting when i take the same steps in different ways:
//Example 1
m = 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 down below 1
//Example2
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 ); // output down below 2
Both ways have the same order of actions, namely
- identity
- rotate 90 deg around x
- translate by 10x, 20y
However, the output is not the same, here is output 1:
[1, 0, 0, 0, 0, 6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766e-17, 0, 10, -30, 20.000000000000004, 1]
here is output 2
[1, 0, 0, 0, 0, 6.123233995736766e-17, 1, 0, 0, -1, 6.123233995736766e-17, 0, 10, 20, 30, 1]
Why is the outcome different, when i'm seemingly taking the same steps?