diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-02-03 17:41:36 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-02-03 17:41:36 -0500 |
| commit | 220320494c60c154e84c579f86d2dfdd8f41be2f (patch) | |
| tree | e86a36f3b2583567370bc356583b595e4b91c8b2 /public/assets/javascripts/rectangles/models/vec2.js | |
| parent | 673cd38ccb8a9c6ba7ec0a879fc96dcc580b046c (diff) | |
orthographic polyline
Diffstat (limited to 'public/assets/javascripts/rectangles/models/vec2.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/models/vec2.js | 5 |
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 |
