B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Translates a matrix by the given vector.
   *
   * @param {Array} aMat
   *                mat4 to translate
   * @param {Array} aVec
   *                vec3 specifying the translation
   * @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
   */
Translates a matrix by the given vector.
@param {Array} aMat
mat4 to translate
@param {Array} aVec
vec3 specifying the translation
@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
Translates a matrix by the given vector . @param { Array } aMat mat4 to translate @param { Array } aVec vec3 specifying the translation @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_translate(aMat, aVec, aDest)
  {
    let x = aVec[0];
    let y = aVec[1];
    let z = aVec[2];
    if (!aDest || aMat === aDest) {
      aMat[12] = aMat[0] * x + aMat[4] * y + aMat[8] * z + aMat[12];
      aMat[13] = aMat[1] * x + aMat[5] * y + aMat[9] * z + aMat[13];
      aMat[14] = aMat[2] * x + aMat[6] * y + aMat[10] * z + aMat[14];
      aMat[15] = aMat[3] * x + aMat[7] * y + aMat[11] * z + aMat[15];
      return 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];
    aDest[0] = a00;
    aDest[1] = a01;
    aDest[2] = a02;
    aDest[3] = a03;
    aDest[4] = a10;
    aDest[5] = a11;
    aDest[6] = a12;
    aDest[7] = a13;
    aDest[8] = a20;
    aDest[9] = a21;
    aDest[10] = a22;
    aDest[11] = a23;
    aDest[12] = a00 * x + a10 * y + a20 * z + aMat[12];
    aDest[13] = a01 * x + a11 * y + a21 * z + aMat[13];
    aDest[14] = a02 * x + a12 * y + a22 * z + aMat[14];
    aDest[15] = a03 * x + a13 * y + a23 * z + aMat[15];
    return aDest;
  }
function M4_translate ( aMat , aVec , aDest ) { let x = aVec [ 0 ] ; let y = aVec [ 1 ] ; let z = aVec [ 2 ] ; if ( ! aDest || aMat === aDest ) { aMat [ 12 ] = aMat [ 0 ] * x + aMat [ 4 ] * y + aMat [ 8 ] * z + aMat [ 12 ] ; aMat [ 13 ] = aMat [ 1 ] * x + aMat [ 5 ] * y + aMat [ 9 ] * z + aMat [ 13 ] ; aMat [ 14 ] = aMat [ 2 ] * x + aMat [ 6 ] * y + aMat [ 10 ] * z + aMat [ 14 ] ; aMat [ 15 ] = aMat [ 3 ] * x + aMat [ 7 ] * y + aMat [ 11 ] * z + aMat [ 15 ] ; return 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 ] ; aDest [ 0 ] = a00 ; aDest [ 1 ] = a01 ; aDest [ 2 ] = a02 ; aDest [ 3 ] = a03 ; aDest [ 4 ] = a10 ; aDest [ 5 ] = a11 ; aDest [ 6 ] = a12 ; aDest [ 7 ] = a13 ; aDest [ 8 ] = a20 ; aDest [ 9 ] = a21 ; aDest [ 10 ] = a22 ; aDest [ 11 ] = a23 ; aDest [ 12 ] = a00 * x + a10 * y + a20 * z + aMat [ 12 ] ; aDest [ 13 ] = a01 * x + a11 * y + a21 * z + aMat [ 13 ] ; aDest [ 14 ] = a02 * x + a12 * y + a22 * z + aMat [ 14 ] ; aDest [ 15 ] = a03 * x + a13 * y + a23 * z + aMat [ 15 ] ; return aDest ; }
Translates a matrix by the given vector.
Translates a matrix by the given vector .