Skip to content

Commit

Permalink
im_web_interface: Quaternion.js has now a norm() function
Browse files Browse the repository at this point in the history
  • Loading branch information
b1willaert authored and Peter Soetens committed Mar 6, 2015
1 parent c397214 commit 9d695ae
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/math/Quaternion.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ Quaternion.prototype.conjugate = function() {
this.z *= -1;
};

/**
* Return the norm of this quaternion.
*/
Quaternion.prototype.norm = function() {
return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
};

/**
* Perform a normalization on this quaternion.
*/
Expand Down Expand Up @@ -81,4 +88,4 @@ Quaternion.prototype.clone = function() {
return new Quaternion(this);
};

module.exports = Quaternion;
module.exports = Quaternion;

0 comments on commit 9d695ae

Please sign in to comment.