diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-08-20 23:33:36 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-08-20 23:33:36 -0400 |
| commit | 272474767b6ed1f419843c7a205c16f934eeb84f (patch) | |
| tree | 5ff43f054a0d34d3698de893a26b9e5b24bce424 /public/assets/javascripts/rectangles/models | |
| parent | 4ead3876f33036a94c0e5f7671df3f1f6d148400 (diff) | |
turn segments into rects
Diffstat (limited to 'public/assets/javascripts/rectangles/models')
| -rw-r--r-- | public/assets/javascripts/rectangles/models/rect.js | 6 | ||||
| -rw-r--r-- | public/assets/javascripts/rectangles/models/vec2.js | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/public/assets/javascripts/rectangles/models/rect.js b/public/assets/javascripts/rectangles/models/rect.js index 92c8c9e..a4756ed 100644 --- a/public/assets/javascripts/rectangles/models/rect.js +++ b/public/assets/javascripts/rectangles/models/rect.js @@ -62,6 +62,12 @@ Rect.prototype.maxDimension = function(){ return abs(this.width) > abs(this.height) ? this.width : this.height } + Rect.prototype.isVertical = function(){ + return this.x.isPoint() + } + Rect.prototype.isHorizontal = function(){ + return this.y.isPoint() + } Rect.prototype.mul = function(n){ this.x.mul(n) diff --git a/public/assets/javascripts/rectangles/models/vec2.js b/public/assets/javascripts/rectangles/models/vec2.js index 290e45e..90a56c6 100644 --- a/public/assets/javascripts/rectangles/models/vec2.js +++ b/public/assets/javascripts/rectangles/models/vec2.js @@ -43,6 +43,9 @@ vec2.prototype.eq = function(v){ return this.a == v.a && this.b == v.b } + vec2.prototype.isPoint = function(){ + return this.a == this.b + } vec2.prototype.add = function(n){ this.a += n this.b += n |
