diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-07-24 14:45:22 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-07-24 14:45:22 -0400 |
| commit | 9261438f86b1faf22a0f8d9a366fb0daa3dd090d (patch) | |
| tree | 20c53a132932afba88c9f1f7af4f0cd9eb9d6ae4 /public/assets/javascripts/rectangles/models/vec2.js | |
| parent | 81bd659b6ba25f28267a0b63e502807e7f5e1ac9 (diff) | |
iterative culling algorithm
Diffstat (limited to 'public/assets/javascripts/rectangles/models/vec2.js')
| -rw-r--r-- | public/assets/javascripts/rectangles/models/vec2.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js index b0c88c1..ee02088 100644 --- a/public/assets/javascripts/rectangles/models/vec2.js +++ b/public/assets/javascripts/rectangles/models/vec2.js @@ -93,6 +93,19 @@ return (this.a < v.b && v.b <= this.b) || (v.a < this.b && this.b <= v.b) } } + vec2.prototype.overlaps = function(v){ + if (this.a == v.a || this.b == v.b) { + return true + } + if (this.a < v.a) { + return (v.a < this.b && this.b < v.b) || (this.a < v.b && v.b < this.b) + } + else if (v.a < this.a) { + return (this.a < v.b && v.b < this.b) || (v.a < this.b && this.b < v.b) + } + } + + vec2.prototype.adjacent = function(v){ if (this.a == v.a || this.b == v.b || this.a == v.b || this.b == v.a) { return true |
