diff options
| author | Julie Lala <jules@okfoc.us> | 2014-04-10 10:36:11 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-04-10 10:36:11 -0400 |
| commit | 218ba4f20989d05ad24a35fafda6f0d39cfa7b89 (patch) | |
| tree | cf6dc0910b8545ab7e75407c287f14c43e77dbb4 | |
| parent | c928a0084480767b75b6ae02532b062570a88306 (diff) | |
midpoint, center
| -rw-r--r-- | rectangles.html | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/rectangles.html b/rectangles.html index 086ce27..8878985 100644 --- a/rectangles.html +++ b/rectangles.html @@ -40,6 +40,9 @@ vec2.prototype.normalize = function(){ } return this } +vec2.prototype.midpoint = function(){ + return lerp(0.5, this.a, this.b) +} vec2.prototype.add = function(n){ this.a += n this.b += n @@ -92,6 +95,9 @@ function rect (x0,y0,x1,y1){ rect.prototype.clone = function(){ return new rect( this.x.clone(), this.y.clone() ) } +rect.prototype.center = function(){ + return new vec2(this.x.midpoint(), this.y.midpoint()) +} rect.prototype.normalize = function(){ this.x.normalize().add(this.translation.a) this.y.normalize().add(this.translation.b) |
