B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Performs a matrix multiplication.
   *
   * @param {Array} aMat
   *                first operand
   * @param {Array} aMat2
   *                second operand
   * @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
   */
Performs a matrix multiplication.
@param {Array} aMat
first operand
@param {Array} aMat2
second operand
@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
Performs a matrix multiplication . @param { Array } aMat first operand @param { Array } aMat2 second operand @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_multiply(aMat, aMat2, aDest)
  {
    if (!aDest) {
      aDest = aMat;
    }
    let a00 = aMat[0], a01 = aMat[1], a02 = aMat[2], a03 = aMat[3];
    let a10 = aMat[4], a11 = aMat[5], a12 = aMat[6], a13 = aMat[7];
    let a20 = aMat[8], a21 = aMat[9], a22 = aMat[10], a23 = aMat[11];
    let a30 = aMat[12], a31 = aMat[13], a32 = aMat[14], a33 = aMat[15];
    let b00 = aMat2[0], b01 = aMat2[1], b02 = aMat2[2], b03 = aMat2[3];
    let b10 = aMat2[4], b11 = aMat2[5], b12 = aMat2[6], b13 = aMat2[7];
    let b20 = aMat2[8], b21 = aMat2[9], b22 = aMat2[10], b23 = aMat2[11];
    let b30 = aMat2[12], b31 = aMat2[13], b32 = aMat2[14], b33 = aMat2[15];
    aDest[0] = b00 * a00 + b01 * a10 + b02 * a20 + b03 * a30;
    aDest[1] = b00 * a01 + b01 * a11 + b02 * a21 + b03 * a31;
    aDest[2] = b00 * a02 + b01 * a12 + b02 * a22 + b03 * a32;
    aDest[3] = b00 * a03 + b01 * a13 + b02 * a23 + b03 * a33;
    aDest[4] = b10 * a00 + b11 * a10 + b12 * a20 + b13 * a30;
    aDest[5] = b10 * a01 + b11 * a11 + b12 * a21 + b13 * a31;
    aDest[6] = b10 * a02 + b11 * a12 + b12 * a22 + b13 * a32;
    aDest[7] = b10 * a03 + b11 * a13 + b12 * a23 + b13 * a33;
    aDest[8] = b20 * a00 + b21 * a10 + b22 * a20 + b23 * a30;
    aDest[9] = b20 * a01 + b21 * a11 + b22 * a21 + b23 * a31;
    aDest[10] = b20 * a02 + b21 * a12 + b22 * a22 + b23 * a32;
    aDest[11] = b20 * a03 + b21 * a13 + b22 * a23 + b23 * a33;
    aDest[12] = b30 * a00 + b31 * a10 + b32 * a20 + b33 * a30;
    aDest[13] = b30 * a01 + b31 * a11 + b32 * a21 + b33 * a31;
    aDest[14] = b30 * a02 + b31 * a12 + b32 * a22 + b33 * a32;
    aDest[15] = b30 * a03 + b31 * a13 + b32 * a23 + b33 * a33;
    return aDest;
  }
function M4_multiply ( aMat , aMat2 , aDest ) { if ( ! aDest ) { aDest = aMat ; } let a00 = aMat [ 0 ] , a01 = aMat [ 1 ] , a02 = aMat [ 2 ] , a03 = aMat [ 3 ] ; let a10 = aMat [ 4 ] , a11 = aMat [ 5 ] , a12 = aMat [ 6 ] , a13 = aMat [ 7 ] ; let a20 = aMat [ 8 ] , a21 = aMat [ 9 ] , a22 = aMat [ 10 ] , a23 = aMat [ 11 ] ; let a30 = aMat [ 12 ] , a31 = aMat [ 13 ] , a32 = aMat [ 14 ] , a33 = aMat [ 15 ] ; let b00 = aMat2 [ 0 ] , b01 = aMat2 [ 1 ] , b02 = aMat2 [ 2 ] , b03 = aMat2 [ 3 ] ; let b10 = aMat2 [ 4 ] , b11 = aMat2 [ 5 ] , b12 = aMat2 [ 6 ] , b13 = aMat2 [ 7 ] ; let b20 = aMat2 [ 8 ] , b21 = aMat2 [ 9 ] , b22 = aMat2 [ 10 ] , b23 = aMat2 [ 11 ] ; let b30 = aMat2 [ 12 ] , b31 = aMat2 [ 13 ] , b32 = aMat2 [ 14 ] , b33 = aMat2 [ 15 ] ; aDest [ 0 ] = b00 * a00 + b01 * a10 + b02 * a20 + b03 * a30 ; aDest [ 1 ] = b00 * a01 + b01 * a11 + b02 * a21 + b03 * a31 ; aDest [ 2 ] = b00 * a02 + b01 * a12 + b02 * a22 + b03 * a32 ; aDest [ 3 ] = b00 * a03 + b01 * a13 + b02 * a23 + b03 * a33 ; aDest [ 4 ] = b10 * a00 + b11 * a10 + b12 * a20 + b13 * a30 ; aDest [ 5 ] = b10 * a01 + b11 * a11 + b12 * a21 + b13 * a31 ; aDest [ 6 ] = b10 * a02 + b11 * a12 + b12 * a22 + b13 * a32 ; aDest [ 7 ] = b10 * a03 + b11 * a13 + b12 * a23 + b13 * a33 ; aDest [ 8 ] = b20 * a00 + b21 * a10 + b22 * a20 + b23 * a30 ; aDest [ 9 ] = b20 * a01 + b21 * a11 + b22 * a21 + b23 * a31 ; aDest [ 10 ] = b20 * a02 + b21 * a12 + b22 * a22 + b23 * a32 ; aDest [ 11 ] = b20 * a03 + b21 * a13 + b22 * a23 + b23 * a33 ; aDest [ 12 ] = b30 * a00 + b31 * a10 + b32 * a20 + b33 * a30 ; aDest [ 13 ] = b30 * a01 + b31 * a11 + b32 * a21 + b33 * a31 ; aDest [ 14 ] = b30 * a02 + b31 * a12 + b32 * a22 + b33 * a32 ; aDest [ 15 ] = b30 * a03 + b31 * a13 + b32 * a23 + b33 * a33 ; return aDest ; }
Performs a matrix multiplication.
Performs a matrix multiplication .