Skip to content

Commit

Permalink
Fixed #2 and #4
Browse files Browse the repository at this point in the history
  • Loading branch information
ls-yannick committed Jan 2, 2013
1 parent 46c2603 commit 005bfc0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,14 @@ Cannon.Math.Vector2D = Cannon.ClassFactory.extend({
return new Cannon.Math.Vector2D(this.x-v2.x, this.y-v2.y);
},
/**
Determines whether two vectors are equal
@param (Vector2D) toCompare
@type Boolean
*/
equals: function(toCompare){
return (this.x == toCompare.x && this.y == toCompare.y);
},
/**
Returns the right normal of the current vector
@type Vector2D
@return A new vector
Expand All @@ -243,6 +251,15 @@ Cannon.Math.Vector2D = Cannon.ClassFactory.extend({
return new Cannon.Math.Vector2D( this.y * -1, this.x);
},
/**
Returns the left normal of the current vector
@type Vector2D
@return A new vector
*/
leftNormal: function()
{
return new Cannon.Math.Vector2D( this.y, this.x * -1);
},
/**
Returns a bector representing the direction of the current vector
@type Vector2D
@return A new vector
Expand Down

0 comments on commit 005bfc0

Please sign in to comment.