B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Transforms a vec4 with the given matrix.
   *
   * @param {Array} aMat
   *                mat4 to transform the vector with
   * @param {Array} aVec
   *                vec4 to transform
   * @param {Array} aDest
   *                optional, vec4 receiving operation result
   *                if not specified result is written to the first operand
   *
   * @return {Array} the destination vec4 if specified, vec4 operand otherwise
   */
Transforms a vec4 with the given matrix.
@param {Array} aMat
mat4 to transform the vector with
@param {Array} aVec
vec4 to transform
@param {Array} aDest
optional, vec4 receiving operation result
if not specified result is written to the first operand

@return {Array} the destination vec4 if specified, vec4 operand otherwise
Transforms a vec4 with the given matrix . @param { Array } aMat mat4 to transform the vector with @param { Array } aVec vec4 to transform @param { Array } aDest optional vec4 receiving operation result if not specified result is written to the first operand @return { Array } the destination vec4 if specified vec4 operand otherwise
function M4_multiplyVec4(aMat, aVec, aDest)
  {
    if (!aDest) {
      aDest = aVec;
    }
    let x = aVec[0];
    let y = aVec[1];
    let z = aVec[2];
    let w = aVec[3];
    aDest[0] = aMat[0] * x + aMat[4] * y + aMat[8]  * z + aMat[12] * w;
    aDest[1] = aMat[1] * x + aMat[5] * y + aMat[9]  * z + aMat[13] * w;
    aDest[2] = aMat[2] * x + aMat[6] * y + aMat[10] * z + aMat[14] * w;
    aDest[3] = aMat[3] * x + aMat[7] * y + aMat[11] * z + aMat[15] * w;
    return aDest;
  }
function M4_multiplyVec4 ( aMat , aVec , aDest ) { if ( ! aDest ) { aDest = aVec ; } let x = aVec [ 0 ] ; let y = aVec [ 1 ] ; let z = aVec [ 2 ] ; let w = aVec [ 3 ] ; aDest [ 0 ] = aMat [ 0 ] * x + aMat [ 4 ] * y + aMat [ 8 ] * z + aMat [ 12 ] * w ; aDest [ 1 ] = aMat [ 1 ] * x + aMat [ 5 ] * y + aMat [ 9 ] * z + aMat [ 13 ] * w ; aDest [ 2 ] = aMat [ 2 ] * x + aMat [ 6 ] * y + aMat [ 10 ] * z + aMat [ 14 ] * w ; aDest [ 3 ] = aMat [ 3 ] * x + aMat [ 7 ] * y + aMat [ 11 ] * z + aMat [ 15 ] * w ; return aDest ; }
Transforms a vec4 with the given matrix.
Transforms a vec4 with the given matrix .