Native object(s) to convert quaternion to rotation matrix ??

    Jun 21 2012 | 12:04 pm
    Hi there,
    is there a couple of objects to convert quaternion to rotation matrix ??

    • Jun 21 2012 | 12:41 pm
      I guess there isn't.
      I looked for them ... no success.
      so I decided to use jit.gen...
      posting the whole calculation in another thread more global.
    • Jun 21 2012 | 6:19 pm
      you can convert a quaternion to a rotation matrix using the jit.anim.node.
      retrieve the @transform attribute (after applying the rotation and updating the node), and discard the last row and last column. this is the rotation matrix.
      note, this will also contain any scaling transformations, so don't modify the @scale attribute.
    • Jun 21 2012 | 7:15 pm
      at least, I would have dived further in jit.gen !!
      okay about the rot matrix easily retrievable.
      I now have to multiply it by all objects coordinates in my global named matrix.
      ... digging that right now.
      especially there are many ways... I'd go with jit.gen because i really begin to like it and indeed, it is very very fast compared to my first poor design in JAVA :-/
    • Jun 22 2012 | 7:09 am
      (struggling with a so basic stuff... using this matrix 3x3 mono plane with my 4 planes 1xn matrix with objects coordinates.. planes confuse me)
    • Jun 22 2012 | 7:41 am
      Robert, can you do something similar to do the opposite: translate a rotation or transform matrix to quaternion?
    • Jun 22 2012 | 5:17 pm
      hi zachary. i was about to answer yes. setting the @transform attribute of jit.anim.node decomposes the proper position, quat, and scale values into the respective attributes.
      however, when testing this, it looks like there's a bug with the quat attribute not getting properly updated.
      this will be fixed for the next update.
      here's how it's supposed to work, for future reference:
    • Jun 22 2012 | 5:26 pm
      interesting to have the conversion in both direction.
      Robert, would you help me with my (last straight) road to matrix multiplication ?
      I tried using [jit.mult], I also tried to pack unpack to play with planes but without success.
    • Jun 22 2012 | 6:14 pm
      hi julien. transforming a vector by a rotation matrix is not a simple pointwise multiplication of the the cells.
      i'm not sure if that's what you're trying to do.
      in any case, if you have a bunch of vectors (object positions) and a rotation matrix, it should not be too difficult to write the code (javascript or otherwise) to transform the vectors.
      or use, which will multiply a vector (jit.matrix 1 float32 3) by a rotation matrix (jit.matirx 1 float32 3 3)
      plenty of online information on this:
    • Jun 22 2012 | 6:25 pm
      This is "only" for calculating my azimuth & elevation.
      For this purpose, I need to apply the rotation matrix given by the cam to each objects coordinates... right?
      ok for your links and especially the pure matrix objects.
      before that I'll check and recheck the first statement of this post =-)
    • Jun 22 2012 | 6:36 pm
      (just to add: this has to happen each frame very fast.. I'd be afraid to use JS for that but I'll try for sure if you would confirm if my vectors transformation makes sense to calculate ae)
    • Sep 10 2012 | 7:51 pm
      Hi guys,
      Looks like I got it but for some reason I don't get the matrix output of my js to work (outlet 0). I doubled it with a message output and that seems to work fine (outlet 1).
      Surely it's something basic but what am I doing wrong here?
      Tanx, D.
    • Sep 10 2012 | 7:52 pm
      // JS as text :
      // transform.js
      this.autowatch = 1;
      var result_mat = new JitterMatrix(3, "float32", 1, 1);
      var vec= new Array(3);
      var result = new Array(3);
      var mat1
      var mat2;
      function jit_matrix(mtx_in) {
      mat1 = new JitterObject("jit.matrix", mtx_in);
      //var cell = mat.getcell(0, 0);
      vec = mat1.getcell(0,0);
      result[0] = vec[0] * mat2.getcell(0,0) + vec[1] * mat2.getcell(1,0) + vec[2] * mat2.getcell(2,0) + mat2.getcell(3,0);
      result[1] = vec[0] * mat2.getcell(0,1) + vec[1] * mat2.getcell(1,1) + vec[2] * mat2.getcell(2,1) + mat2.getcell(3,1);
      result[2] = vec[0] * mat2.getcell(0,2) + vec[1] * mat2.getcell(1,2) + vec[2] * mat2.getcell(2,2) + mat2.getcell(3,2);
      result_mat.setall(result[0], result[1] , result[2]);
      outlet(0, "jit_matrix",; // output as matrix
      outlet(1, result[0] +" "+ result[1] +" "+ result[2]); // output as message
      } else {
      mat2 = new JitterObject("jit.matrix", mtx_in);
    • Sep 10 2012 | 8:13 pm
      you need to use "parseFloat" on the args to the setall message, so that javascript will cast from Object to Float.
    • Sep 11 2012 | 1:21 pm
    • Sep 11 2012 | 6:19 pm
      Rob, I'm getting funky results with this. With float inputs it's fine but when I input a decimal (eg. 1.0) it comes out multiplied by then (eg. 10.0) even though the transform matrix is unity. Not sure if it's parseFloat or something else.
      // transform.js
      this.autowatch = 1;
      var result_mat = new JitterMatrix(3, "float32", 1, 1);
      var vec= new Array(3);
      var result = new Array(3);
      var mat1
      var mat2;
      var x;
      var y;
      var z;
      function jit_matrix(mtx_in) {
      mat1 = new JitterObject("jit.matrix", mtx_in);
      vec = mat1.getcell(0,0);
      x = vec[0] * mat2.getcell(0,0) + vec[1] * mat2.getcell(0,1) + vec[2] * mat2.getcell(0,2) + mat2.getcell(0,3);
      y = vec[0] * mat2.getcell(1,0) + vec[1] * mat2.getcell(1,1) + vec[2] * mat2.getcell(1,2) + mat2.getcell(1,3);
      z = vec[0] * mat2.getcell(2,0) + vec[1] * mat2.getcell(2,1) + vec[2] * mat2.getcell(2,2) + mat2.getcell(2,3);
      outlet(1, x+" " +y+" "+z+"n"); // output as message before parseFloat()
      result_mat.setcell2d(0,0,parseFloat(x), parseFloat(y), parseFloat(z));
      outlet(0, "jit_matrix",; // output as matrix
      // outlet(1, result_mat.getcell(0,0)); // output as message
      } else {
      mat2 = new JitterObject("jit.matrix", mtx_in);
    • Sep 11 2012 | 6:32 pm
      Also, the 4th row of the transform matrix - translation - doesn't seem to have any effect. Is it perhaps the use of the 'vec' array that's messing things up?
    • Sep 11 2012 | 8:51 pm
      I made an ugly jit.gen alternative for now but I think it's buggy as well. Rotating around X seems fine but around Y and Z is funky. Don't see why. Anyone?
      The math's according to the links by Wes:
    • Sep 11 2012 | 10:54 pm
      i don't think you were building your rotation matrix properly.
      below is a patch using gen, based on this link:
    • Sep 12 2012 | 7:17 am
      The 4x4 matrix is not just for rotation but also translation and scaling. What I'm trying to achieve is aligning 2 kinect skeletons taken from different camera angles. I have Meshlab calculate the transform between the 2 by ICP (iterative closest point) registration. It returns a transform matrix like this:
      -0.35 -0.03 -0.94 0.0
      0.16 0.98 -0.09 0.0
      0.92 -0.18 -0.34 0.0
      -2.82 0.76 4.2 1.0
      Since the math in Wes' link works with 4x4 matrices I was hoping to get it to work that way.