B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Transposes a mat4 (flips the values over the diagonal).
   *
   * @param {Array} aMat
   *                mat4 to transpose
   * @param {Array} aDest
   *                optional, mat4 receiving operation result
   *                if not specified result is written to the first operand
   *
   * @return {Array} the destination mat4 if specified, first operand otherwise
   */
Transposes a mat4 (flips the values over the diagonal).
@param {Array} aMat
mat4 to transpose
@param {Array} aDest
optional, mat4 receiving operation result
if not specified result is written to the first operand

@return {Array} the destination mat4 if specified, first operand otherwise
Transposes a mat4 ( flips the values over the diagonal ) . @param { Array } aMat mat4 to transpose @param { Array } aDest optional mat4 receiving operation result if not specified result is written to the first operand @return { Array } the destination mat4 if specified first operand otherwise
function M4_transpose(aMat, aDest)
  {
    if (!aDest || aMat === aDest) {
      let a01 = aMat[1];
      let a02 = aMat[2];
      let a03 = aMat[3];
      let a12 = aMat[6];
      let a13 = aMat[7];
      let a23 = aMat[11];
      aMat[1] = aMat[4];
      aMat[2] = aMat[8];
      aMat[3] = aMat[12];
      aMat[4] = a01;
      aMat[6] = aMat[9];
      aMat[7] = aMat[13];
      aMat[8] = a02;
      aMat[9] = a12;
      aMat[11] = aMat[14];
      aMat[12] = a03;
      aMat[13] = a13;
      aMat[14] = a23;
      return aMat;
    }
    aDest[0] = aMat[0];
    aDest[1] = aMat[4];
    aDest[2] = aMat[8];
    aDest[3] = aMat[12];
    aDest[4] = aMat[1];
    aDest[5] = aMat[5];
    aDest[6] = aMat[9];
    aDest[7] = aMat[13];
    aDest[8] = aMat[2];
    aDest[9] = aMat[6];
    aDest[10] = aMat[10];
    aDest[11] = aMat[14];
    aDest[12] = aMat[3];
    aDest[13] = aMat[7];
    aDest[14] = aMat[11];
    aDest[15] = aMat[15];
    return aDest;
  }
function M4_transpose ( aMat , aDest ) { if ( ! aDest || aMat === aDest ) { let a01 = aMat [ 1 ] ; let a02 = aMat [ 2 ] ; let a03 = aMat [ 3 ] ; let a12 = aMat [ 6 ] ; let a13 = aMat [ 7 ] ; let a23 = aMat [ 11 ] ; aMat [ 1 ] = aMat [ 4 ] ; aMat [ 2 ] = aMat [ 8 ] ; aMat [ 3 ] = aMat [ 12 ] ; aMat [ 4 ] = a01 ; aMat [ 6 ] = aMat [ 9 ] ; aMat [ 7 ] = aMat [ 13 ] ; aMat [ 8 ] = a02 ; aMat [ 9 ] = a12 ; aMat [ 11 ] = aMat [ 14 ] ; aMat [ 12 ] = a03 ; aMat [ 13 ] = a13 ; aMat [ 14 ] = a23 ; return aMat ; } aDest [ 0 ] = aMat [ 0 ] ; aDest [ 1 ] = aMat [ 4 ] ; aDest [ 2 ] = aMat [ 8 ] ; aDest [ 3 ] = aMat [ 12 ] ; aDest [ 4 ] = aMat [ 1 ] ; aDest [ 5 ] = aMat [ 5 ] ; aDest [ 6 ] = aMat [ 9 ] ; aDest [ 7 ] = aMat [ 13 ] ; aDest [ 8 ] = aMat [ 2 ] ; aDest [ 9 ] = aMat [ 6 ] ; aDest [ 10 ] = aMat [ 10 ] ; aDest [ 11 ] = aMat [ 14 ] ; aDest [ 12 ] = aMat [ 3 ] ; aDest [ 13 ] = aMat [ 7 ] ; aDest [ 14 ] = aMat [ 11 ] ; aDest [ 15 ] = aMat [ 15 ] ; return aDest ; }
Transposes a mat4 (flips the values over the diagonal).
Transposes a mat4 ( flips the values over the diagonal ) .