From 1af8f41cc88e3c57bfabe6d4a5dcd83fc4a0e1bc Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Thu, 17 Apr 2014 02:32:53 -0400 Subject: further code bath, fix minimap orientation/translation --- assets/javascripts/rectangles/vec2.js | 81 ----------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 assets/javascripts/rectangles/vec2.js (limited to 'assets/javascripts/rectangles/vec2.js') diff --git a/assets/javascripts/rectangles/vec2.js b/assets/javascripts/rectangles/vec2.js deleted file mode 100644 index 4e2ad36..0000000 --- a/assets/javascripts/rectangles/vec2.js +++ /dev/null @@ -1,81 +0,0 @@ -function vec2(a,b){ - this.a = a - this.b = b -} -vec2.prototype.magnitude = function(){ - return this.b-this.a -} -vec2.prototype.length = function(){ - return abs(this.b-this.a) -} -vec2.prototype.clone = function(){ - return new vec2(this.a, this.b) -} -vec2.prototype.abs = function(){ - if (this.b < this.a) { - this.a = this.a ^ this.b - this.b = this.a ^ this.b - this.a = this.a ^ this.b - } - return this -} -vec2.prototype.midpoint = function(){ - return lerp(0.5, this.a, this.b) -} -vec2.prototype.eq = function(v){ - return this.a == v.a && this.b == v.b -} -vec2.prototype.add = function(n){ - this.a += n - this.b += n -} -vec2.prototype.sub = function(n){ - this.a -= n - this.b -= n -} -vec2.prototype.mul = function(n){ - this.a *= n - this.b *= n -} -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 -} -vec2.prototype.intersects = function(v){ - if (this.a < v.a) { - return (v.a < this.b && this.b <= v.b) || (this.a < v.b && v.b <= this.b) - } - else if (this.a == v.a) { - return true - } - else if (this.a > v.a) { - return (this.a < v.b && v.b <= this.b) || (v.a < this.b && this.b <= v.b) - } -} -vec2.prototype.union = function(v){ - if (this.intersects(v)) { - return new vec2( min(this.a,v.a), max(this.b, v.b) ) - } -} -vec2.prototype.intersection = function(v){ - if (this.intersects(v)) { - return new vec2( max(this.a,v.a), min(this.b, v.b) ) - } -} -vec2.prototype.toString = function(){ - return "[" + this.a + " " + this.b + "]" -} -vec2.prototype.quantize = function(n){ - n = n || 10 - this.a = quantize(this.a, n) - this.b = quantize(this.b, n) -} - -- cgit v1.2.3-70-g09d2