B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Calculates a 4x4 matrix from the given quat4.
   *
   * @param {Array} aQuat
   *                quat4 to create matrix from
   * @param {Array} aDest
   *                optional, mat4 receiving the initialization result
   *                if not specified, a new matrix is created
   *
   * @return {Array} the destination mat4 if specified, first operand otherwise
   */
Calculates a 4x4 matrix from the given quat4.
@param {Array} aQuat
quat4 to create matrix from
@param {Array} aDest
optional, mat4 receiving the initialization result
if not specified, a new matrix is created

@return {Array} the destination mat4 if specified, first operand otherwise
Calculates a 4x4 matrix from the given quat4 . @param { Array } aQuat quat4 to create matrix from @param { Array } aDest optional mat4 receiving the initialization result if not specified a new matrix is created @return { Array } the destination mat4 if specified first operand otherwise
function Q4_toMat4(aQuat, aDest)
  {
    if (!aDest) {
      aDest = new Float32Array(16);
    }
    let x = aQuat[0];
    let y = aQuat[1];
    let z = aQuat[2];
    let w = aQuat[3];
    let x2 = x + x;
    let y2 = y + y;
    let z2 = z + z;
    let xx = x * x2;
    let xy = x * y2;
    let xz = x * z2;
    let yy = y * y2;
    let yz = y * z2;
    let zz = z * z2;
    let wx = w * x2;
    let wy = w * y2;
    let wz = w * z2;
    aDest[0] = 1 - (yy + zz);
    aDest[1] = xy - wz;
    aDest[2] = xz + wy;
    aDest[3] = 0;
    aDest[4] = xy + wz;
    aDest[5] = 1 - (xx + zz);
    aDest[6] = yz - wx;
    aDest[7] = 0;
    aDest[8] = xz - wy;
    aDest[9] = yz + wx;
    aDest[10] = 1 - (xx + yy);
    aDest[11] = 0;
    aDest[12] = 0;
    aDest[13] = 0;
    aDest[14] = 0;
    aDest[15] = 1;
    return aDest;
  }
function Q4_toMat4 ( aQuat , aDest ) { if ( ! aDest ) { aDest = new Float32Array ( 16 ) ; } let x = aQuat [ 0 ] ; let y = aQuat [ 1 ] ; let z = aQuat [ 2 ] ; let w = aQuat [ 3 ] ; let x2 = x + x ; let y2 = y + y ; let z2 = z + z ; let xx = x * x2 ; let xy = x * y2 ; let xz = x * z2 ; let yy = y * y2 ; let yz = y * z2 ; let zz = z * z2 ; let wx = w * x2 ; let wy = w * y2 ; let wz = w * z2 ; aDest [ 0 ] = 1 - ( yy + zz ) ; aDest [ 1 ] = xy - wz ; aDest [ 2 ] = xz + wy ; aDest [ 3 ] = 0 ; aDest [ 4 ] = xy + wz ; aDest [ 5 ] = 1 - ( xx + zz ) ; aDest [ 6 ] = yz - wx ; aDest [ 7 ] = 0 ; aDest [ 8 ] = xz - wy ; aDest [ 9 ] = yz + wx ; aDest [ 10 ] = 1 - ( xx + yy ) ; aDest [ 11 ] = 0 ; aDest [ 12 ] = 0 ; aDest [ 13 ] = 0 ; aDest [ 14 ] = 0 ; aDest [ 15 ] = 1 ; return aDest ; }
Calculates a 4x4 matrix from the given quat4.
Calculates a 4x4 matrix from the given quat4 .