B2G/gecko/browser/devtools/tilt/TiltMath.jsm
/**
   * Rotates a matrix by the given angle around the X axis.
   *
   * @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 X axis.
@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 X axis . @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_rotateX(aMat, aAngle, aDest)
  {
    let s = Math.sin(aAngle);
    let c = Math.cos(aAngle);
    let a10 = aMat[4], a11 = aMat[5], a12 = aMat[6], a13 = aMat[7];
    let a20 = aMat[8], a21 = aMat[9], a22 = aMat[10], a23 = aMat[11];
    if (!aDest) {
      aDest = aMat;
    } else if (aMat !== aDest) {
      aDest[0] = aMat[0];
      aDest[1] = aMat[1];
      aDest[2] = aMat[2];
      aDest[3] = aMat[3];
      aDest[12] = aMat[12];
      aDest[13] = aMat[13];
      aDest[14] = aMat[14];
      aDest[15] = aMat[15];
    }
    aDest[4] = a10 * c + a20 * s;
    aDest[5] = a11 * c + a21 * s;
    aDest[6] = a12 * c + a22 * s;
    aDest[7] = a13 * c + a23 * s;
    aDest[8] = a10 * -s + a20 * c;
    aDest[9] = a11 * -s + a21 * c;
    aDest[10] = a12 * -s + a22 * c;
    aDest[11] = a13 * -s + a23 * c;
    return aDest;
  }
function M4_rotateX ( aMat , aAngle , aDest ) { let s = Math . sin ( aAngle ) ; let c = Math . cos ( aAngle ) ; let a10 = aMat [ 4 ] , a11 = aMat [ 5 ] , a12 = aMat [ 6 ] , a13 = aMat [ 7 ] ; let a20 = aMat [ 8 ] , a21 = aMat [ 9 ] , a22 = aMat [ 10 ] , a23 = aMat [ 11 ] ; if ( ! aDest ) { aDest = aMat ; } else if ( aMat !== aDest ) { aDest [ 0 ] = aMat [ 0 ] ; aDest [ 1 ] = aMat [ 1 ] ; aDest [ 2 ] = aMat [ 2 ] ; aDest [ 3 ] = aMat [ 3 ] ; aDest [ 12 ] = aMat [ 12 ] ; aDest [ 13 ] = aMat [ 13 ] ; aDest [ 14 ] = aMat [ 14 ] ; aDest [ 15 ] = aMat [ 15 ] ; } aDest [ 4 ] = a10 * c + a20 * s ; aDest [ 5 ] = a11 * c + a21 * s ; aDest [ 6 ] = a12 * c + a22 * s ; aDest [ 7 ] = a13 * c + a23 * s ; aDest [ 8 ] = a10 * - s + a20 * c ; aDest [ 9 ] = a11 * - s + a21 * c ; aDest [ 10 ] = a12 * - s + a22 * c ; aDest [ 11 ] = a13 * - s + a23 * c ; return aDest ; }
Rotates a matrix by the given angle around the X axis.
Rotates a matrix by the given angle around the X axis .