quaternion.js
function() {

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

      if (y === 0 && z === 0) {
        return new Quaternion(
                logHypot(w, x),
                Math.atan2(x, w), 0, 0);
      }

      var qNorm2 = x * x + y * y + z * z + w * w;
      var vNorm = Math.sqrt(x * x + y * y + z * z);

      var scale = Math.atan2(vNorm, w) / vNorm;

      return new Quaternion(
              Math.log(qNorm2) * 0.5,
              x * scale,
              y * scale,
              z * scale);
    }
function() {

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

      if (y === 0 && z === 0) {
        return new Quaternion(
                logHypot(w, x),
                Math.atan2(x, w), 0, 0);
      }

      var qNorm2 = x * x + y * y + z * z + w * w;
      var vNorm = Math.sqrt(x * x + y * y + z * z);

      var scale = Math.atan2(vNorm, w) / vNorm;

      return new Quaternion(
              Math.log(qNorm2) * 0.5,
              x * scale,
              y * scale,
              z * scale);
    }
function ( ) { var w = this [ 'w' ] ; var x = this [ 'x' ] ; var y = this [ 'y' ] ; var z = this [ 'z' ] ; if ( y === 0 && z === 0 ) { return new Quaternion ( logHypot ( w , x ) , Math . atan2 ( x , w ) , 0 , 0 ) ; } var qNorm2 = x * x + y * y + z * z + w * w ; var vNorm = Math . sqrt ( x * x + y * y + z * z ) ; var scale = Math . atan2 ( vNorm , w ) / vNorm ; return new Quaternion ( Math . log ( qNorm2 ) * 0.5 , x * scale , y * scale , z * scale ) ; }
Calculates the natural logarithm of the quaternion

@returns {Quaternion}
Calculates the natural logarithm of the quaternion