B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Transforms a vec3 with the given quaternion.
   *
   * @param {Array} aQuat
   *                quat4 to transform the vector with
   * @param {Array} aVec
   *                vec3 to transform
   * @param {Array} aDest
   *                optional, vec3 receiving the 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 quaternion.
@param {Array} aQuat
quat4 to transform the vector with
@param {Array} aVec
vec3 to transform
@param {Array} aDest
optional, vec3 receiving the 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 quaternion . @param { Array } aQuat quat4 to transform the vector with @param { Array } aVec vec3 to transform @param { Array } aDest optional vec3 receiving the operation result if not specified result is written to the first operand @return { Array } the destination vec3 if specified aVec operand otherwise
function Q4_multiplyVec3(aQuat, aVec, aDest)
  {
    if (!aDest) {
      aDest = aVec;
    }
    let x = aVec[0];
    let y = aVec[1];
    let z = aVec[2];
    let qx = aQuat[0];
    let qy = aQuat[1];
    let qz = aQuat[2];
    let qw = aQuat[3];
    let ix = qw * x + qy * z - qz * y;
    let iy = qw * y + qz * x - qx * z;
    let iz = qw * z + qx * y - qy * x;
    let iw = -qx * x - qy * y - qz * z;
    aDest[0] = ix * qw + iw * -qx + iy * -qz - iz * -qy;
    aDest[1] = iy * qw + iw * -qy + iz * -qx - ix * -qz;
    aDest[2] = iz * qw + iw * -qz + ix * -qy - iy * -qx;
    return aDest;
  }
function Q4_multiplyVec3 ( aQuat , aVec , aDest ) { if ( ! aDest ) { aDest = aVec ; } let x = aVec [ 0 ] ; let y = aVec [ 1 ] ; let z = aVec [ 2 ] ; let qx = aQuat [ 0 ] ; let qy = aQuat [ 1 ] ; let qz = aQuat [ 2 ] ; let qw = aQuat [ 3 ] ; let ix = qw * x + qy * z - qz * y ; let iy = qw * y + qz * x - qx * z ; let iz = qw * z + qx * y - qy * x ; let iw = - qx * x - qy * y - qz * z ; aDest [ 0 ] = ix * qw + iw * - qx + iy * - qz - iz * - qy ; aDest [ 1 ] = iy * qw + iw * - qy + iz * - qx - ix * - qz ; aDest [ 2 ] = iz * qw + iw * - qz + ix * - qy - iy * - qx ; return aDest ; }
Transforms a vec3 with the given quaternion.
Transforms a vec3 with the given quaternion .