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

@param {Array} aMat
mat4 to transform the vector with
@param {Array} aVec
vec3 to transform
@param {Array} aDest
optional, vec3 receiving operation result
if not specified result is written to the first operand

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