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

@return {Array} the destination mat3 if specified, first operand otherwise
Transposes a mat3 ( flips the values over the diagonal ) . @param { Array } aMat mat3 to transpose @param { Array } aDest optional mat3 receiving operation result if not specified result is written to the first operand @return { Array } the destination mat3 if specified first operand otherwise
function M3_transpose(aMat, aDest)
  {
    if (!aDest || aMat === aDest) {
      let a01 = aMat[1];
      let a02 = aMat[2];
      let a12 = aMat[5];
      aMat[1] = aMat[3];
      aMat[2] = aMat[6];
      aMat[3] = a01;
      aMat[5] = aMat[7];
      aMat[6] = a02;
      aMat[7] = a12;
      return aMat;
    }
    aDest[0] = aMat[0];
    aDest[1] = aMat[3];
    aDest[2] = aMat[6];
    aDest[3] = aMat[1];
    aDest[4] = aMat[4];
    aDest[5] = aMat[7];
    aDest[6] = aMat[2];
    aDest[7] = aMat[5];
    aDest[8] = aMat[8];
    return aDest;
  }
function M3_transpose ( aMat , aDest ) { if ( ! aDest || aMat === aDest ) { let a01 = aMat [ 1 ] ; let a02 = aMat [ 2 ] ; let a12 = aMat [ 5 ] ; aMat [ 1 ] = aMat [ 3 ] ; aMat [ 2 ] = aMat [ 6 ] ; aMat [ 3 ] = a01 ; aMat [ 5 ] = aMat [ 7 ] ; aMat [ 6 ] = a02 ; aMat [ 7 ] = a12 ; return aMat ; } aDest [ 0 ] = aMat [ 0 ] ; aDest [ 1 ] = aMat [ 3 ] ; aDest [ 2 ] = aMat [ 6 ] ; aDest [ 3 ] = aMat [ 1 ] ; aDest [ 4 ] = aMat [ 4 ] ; aDest [ 5 ] = aMat [ 7 ] ; aDest [ 6 ] = aMat [ 2 ] ; aDest [ 7 ] = aMat [ 5 ] ; aDest [ 8 ] = aMat [ 8 ] ; return aDest ; }
Transposes a mat3 (flips the values over the diagonal).
Transposes a mat3 ( flips the values over the diagonal ) .