summaryrefslogtreecommitdiff
path: root/assets/javascripts/rectangles/vec2.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/javascripts/rectangles/vec2.js')
-rw-r--r--assets/javascripts/rectangles/vec2.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/assets/javascripts/rectangles/vec2.js b/assets/javascripts/rectangles/vec2.js
index f4d6a84..4e2ad36 100644
--- a/assets/javascripts/rectangles/vec2.js
+++ b/assets/javascripts/rectangles/vec2.js
@@ -41,6 +41,11 @@ vec2.prototype.div = function(n){
this.a /= n
this.b /= n
}
+vec2.normalize = function(){
+ var dim = max(this.a, this.b)
+ this.a = this.a/dim
+ this.b = this.b/dim
+}
vec2.prototype.contains = function(n){
return this.a <= n && n <= this.b
}