diff options
Diffstat (limited to 'assets/javascripts/rectangles/models/vec2.js')
| -rw-r--r-- | assets/javascripts/rectangles/models/vec2.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/assets/javascripts/rectangles/models/vec2.js b/assets/javascripts/rectangles/models/vec2.js index 4e2ad36..3105fec 100644 --- a/assets/javascripts/rectangles/models/vec2.js +++ b/assets/javascripts/rectangles/models/vec2.js @@ -28,23 +28,28 @@ vec2.prototype.eq = function(v){ vec2.prototype.add = function(n){ this.a += n this.b += n + return this } vec2.prototype.sub = function(n){ this.a -= n this.b -= n + return this } vec2.prototype.mul = function(n){ this.a *= n this.b *= n + return this } vec2.prototype.div = function(n){ this.a /= n this.b /= n + return this } vec2.normalize = function(){ var dim = max(this.a, this.b) this.a = this.a/dim this.b = this.b/dim + return this } vec2.prototype.contains = function(n){ return this.a <= n && n <= this.b |
