B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Rotates a matrix by the given angle around the Z axix.
   *
   * @param {Array} aMat
   *                mat4 to rotate
   * @param {Number} aAngle
   *                 the angle (in radians) to rotate
   * @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
   */
Rotates a matrix by the given angle around the Z axix.
@param {Array} aMat
mat4 to rotate
@param {Number} aAngle
the angle (in radians) to rotate
@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
Rotates a matrix by the given angle around the Z axix . @param { Array } aMat mat4 to rotate @param { Number } aAngle the angle ( in radians ) to rotate @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_rotateZ(aMat, aAngle, aDest)
  {
    let s = Math.sin(aAngle);
    let c = Math.cos(aAngle);
    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];
    if (!aDest) {
      aDest = aMat;
    } else if (aMat !== aDest) {
      aDest[8] = aMat[8];
      aDest[9] = aMat[9];
      aDest[10] = aMat[10];
      aDest[11] = aMat[11];
      aDest[12] = aMat[12];
      aDest[13] = aMat[13];
      aDest[14] = aMat[14];
      aDest[15] = aMat[15];
    }
    aDest[0] = a00 * c + a10 * s;
    aDest[1] = a01 * c + a11 * s;
    aDest[2] = a02 * c + a12 * s;
    aDest[3] = a03 * c + a13 * s;
    aDest[4] = a00 * -s + a10 * c;
    aDest[5] = a01 * -s + a11 * c;
    aDest[6] = a02 * -s + a12 * c;
    aDest[7] = a03 * -s + a13 * c;
    return aDest;
  }
function M4_rotateZ ( aMat , aAngle , aDest ) { let s = Math . sin ( aAngle ) ; let c = Math . cos ( aAngle ) ; 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 ] ; if ( ! aDest ) { aDest = aMat ; } else if ( aMat !== aDest ) { aDest [ 8 ] = aMat [ 8 ] ; aDest [ 9 ] = aMat [ 9 ] ; aDest [ 10 ] = aMat [ 10 ] ; aDest [ 11 ] = aMat [ 11 ] ; aDest [ 12 ] = aMat [ 12 ] ; aDest [ 13 ] = aMat [ 13 ] ; aDest [ 14 ] = aMat [ 14 ] ; aDest [ 15 ] = aMat [ 15 ] ; } aDest [ 0 ] = a00 * c + a10 * s ; aDest [ 1 ] = a01 * c + a11 * s ; aDest [ 2 ] = a02 * c + a12 * s ; aDest [ 3 ] = a03 * c + a13 * s ; aDest [ 4 ] = a00 * - s + a10 * c ; aDest [ 5 ] = a01 * - s + a11 * c ; aDest [ 6 ] = a02 * - s + a12 * c ; aDest [ 7 ] = a03 * - s + a13 * c ; return aDest ; }
Rotates a matrix by the given angle around the Z axix.
Rotates a matrix by the given angle around the Z axix .