quaternion.js
function() {

      // Q* := Q / |Q|

      // unrolled Q.scale(1 / Q.norm())

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

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

      if (norm < Quaternion['EPSILON']) {
        return Quaternion['ZERO'];
      }

      norm = 1 / norm;

      return new Quaternion(w * norm, x * norm, y * norm, z * norm);
    }
function() {

      // Q* := Q / |Q|

      // unrolled Q.scale(1 / Q.norm())

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

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

      if (norm < Quaternion['EPSILON']) {
        return Quaternion['ZERO'];
      }

      norm = 1 / norm;

      return new Quaternion(w * norm, x * norm, y * norm, z * norm);
    }
function ( ) { // Q* := Q / |Q| // unrolled Q.scale(1 / Q.norm()) var w = this [ 'w' ] ; var x = this [ 'x' ] ; var y = this [ 'y' ] ; var z = this [ 'z' ] ; var norm = Math . sqrt ( w * w + x * x + y * y + z * z ) ; if ( norm < Quaternion [ 'EPSILON' ] ) { return Quaternion [ 'ZERO' ] ; } norm = 1 / norm ; return new Quaternion ( w * norm , x * norm , y * norm , z * norm ) ; }
Normalizes the quaternion to have |Q| = 1 as long as the norm is not zero
Alternative names are the signum, unit or versor

@returns {Quaternion}
Normalizes the quaternion to have |Q| = 1 as long as the norm is not zero Alternative names are the signum unit or versor