summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/rectangles/models/vec2.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-10-02 17:22:05 -0400
committerJules Laplace <jules@okfoc.us>2014-10-02 17:22:05 -0400
commit1ca354257049dd9bf69a3542e2274c50e85ca788 (patch)
tree3583b1af1a7178eb448eab9640ef1546227200d7 /public/assets/javascripts/rectangles/models/vec2.js
parentb1556ef6f9854e08f5bb20907c57a9558005af95 (diff)
parente271f9d7c0b2cf3998d1d8921f1f830bd7bab3ef (diff)
merge
Diffstat (limited to 'public/assets/javascripts/rectangles/models/vec2.js')
-rw-r--r--public/assets/javascripts/rectangles/models/vec2.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js
index 0040435..49613c3 100644
--- a/public/assets/javascripts/rectangles/models/vec2.js
+++ b/public/assets/javascripts/rectangles/models/vec2.js
@@ -37,6 +37,9 @@
vec2.prototype.midpoint = function(){
return lerp(0.5, this.a, this.b)
}
+ vec2.prototype.lerp = function(n){
+ return lerp(n, this.a, this.b)
+ }
vec2.prototype.eq = function(v){
return this.a == v.a && this.b == v.b
}
@@ -60,9 +63,23 @@
this.b /= n
return this
}
+ vec2.prototype.addVec = function(v){
+ this.a += v.a
+ this.b += v.b
+ return this
+ }
+ vec2.prototype.subVec = function(v){
+ this.a -= v.a
+ this.b -= v.b
+ return this
+ }
vec2.prototype.zero = function(){
this.a = this.b = 0
}
+ vec2.prototype.round = function(){
+ this.a = Math.round(this.a)
+ this.b = Math.round(this.b)
+ }
vec2.prototype.setPosition = function(n){
var len = this.length()
this.a = n