quaternion.js
function(d2) {

      var w = this['w'];
      var x = this['x'];
      var y = this['y'];
      var z = this['z'];

      var n = w * w + x * x + y * y + z * z;
      var s = n === 0 ? 0 : 2 / n;
      var wx = s * w * x, wy = s * w * y, wz = s * w * z;
      var xx = s * x * x, xy = s * x * y, xz = s * x * z;
      var yy = s * y * y, yz = s * y * z, zz = s * z * z;

      if (d2) {
        return [
          [1 - (yy + zz), xy - wz, xz + wy],
          [xy + wz, 1 - (xx + zz), yz - wx],
          [xz - wy, yz + wx, 1 - (xx + yy)]];
      }

      return [
        1 - (yy + zz), xy - wz, xz + wy,
        xy + wz, 1 - (xx + zz), yz - wx,
        xz - wy, yz + wx, 1 - (xx + yy)];
    }
function(d2) {

      var w = this['w'];
      var x = this['x'];
      var y = this['y'];
      var z = this['z'];

      var n = w * w + x * x + y * y + z * z;
      var s = n === 0 ? 0 : 2 / n;
      var wx = s * w * x, wy = s * w * y, wz = s * w * z;
      var xx = s * x * x, xy = s * x * y, xz = s * x * z;
      var yy = s * y * y, yz = s * y * z, zz = s * z * z;

      if (d2) {
        return [
          [1 - (yy + zz), xy - wz, xz + wy],
          [xy + wz, 1 - (xx + zz), yz - wx],
          [xz - wy, yz + wx, 1 - (xx + yy)]];
      }

      return [
        1 - (yy + zz), xy - wz, xz + wy,
        xy + wz, 1 - (xx + zz), yz - wx,
        xz - wy, yz + wx, 1 - (xx + yy)];
    }
function ( d2 ) { var w = this [ 'w' ] ; var x = this [ 'x' ] ; var y = this [ 'y' ] ; var z = this [ 'z' ] ; var n = w * w + x * x + y * y + z * z ; var s = n === 0 ? 0 : 2 / n ; var wx = s * w * x , wy = s * w * y , wz = s * w * z ; var xx = s * x * x , xy = s * x * y , xz = s * x * z ; var yy = s * y * y , yz = s * y * z , zz = s * z * z ; if ( d2 ) { return [ [ 1 - ( yy + zz ) , xy - wz , xz + wy ] , [ xy + wz , 1 - ( xx + zz ) , yz - wx ] , [ xz - wy , yz + wx , 1 - ( xx + yy ) ] ] ; } return [ 1 - ( yy + zz ) , xy - wz , xz + wy , xy + wz , 1 - ( xx + zz ) , yz - wx , xz - wy , yz + wx , 1 - ( xx + yy ) ] ; }
Calculates the 3x3 rotation matrix for the current quat

@param {boolean=} d2
@see https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion
@returns {Array}
Calculates the 3x3 rotation matrix for the current quat