summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/models/vec2.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/rectangles/models/vec2.js')
-rw-r--r--public/assets/javascripts/rectangles/models/vec2.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js
index 14d0e6b..290e45e 100644
--- a/public/assets/javascripts/rectangles/models/vec2.js
+++ b/public/assets/javascripts/rectangles/models/vec2.js
@@ -80,6 +80,11 @@
this.a = Math.round(this.a)
this.b = Math.round(this.b)
}
+ vec2.prototype.distanceTo = function(v){
+ var va = (this.a - v.a)
+ var vb = (this.b - v.b)
+ return Math.sqrt( va*va + vb*vb )
+ }
vec2.prototype.setPosition = function(n){
var len = this.length()
this.a = n