From 6f895c8db89ce8ae6295db1dc93284cdb521217c Mon Sep 17 00:00:00 2001 From: Julie Lala Date: Fri, 11 Apr 2014 10:20:57 -0400 Subject: notes --- rect.js | 30 ++++++++++++++++++++++++++++++ rectangles.html | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/rect.js b/rect.js index dcf2d33..f643b6f 100644 --- a/rect.js +++ b/rect.js @@ -58,3 +58,33 @@ rect.prototype.quantize = function(n){ this.x.quantize(n) this.y.quantize(n) } +rect.prototype.reset = function(){ + var copy = this.clone() + copy.sides = 0xf + this.regions = [ copy ] +} +rect.prototype.clipTo = function(r){ + // for each of this rect's regions split the region if necessary + for (var i = 0, len = regions.length; i < len; i++) { + if (regions[i] && regions[i].intersects(r)) { + var splits = regions[i].split(r) + regions.concat(splits) + regions[i] = null + } + } +} +rect.prototype.split = function(r){ + var splits = [] + + + + // 1 split (horizontal) + // 1 split (vertical) + // 2 splits (top left) + // 2 splits (top right) + // 2 splits (bottom left) + // 2 splits (bottom right) + // 3 splits (center) + + return splits +} diff --git a/rectangles.html b/rectangles.html index aa31344..7acc52b 100644 --- a/rectangles.html +++ b/rectangles.html @@ -141,7 +141,6 @@ function solve_rects(){ var left, right for (var i = 0; i < rects.length; i++) { left = rects[i] - left.regions = [] for (var j = 0; j < rects.length; j++) { right = rects[j] if (left.intersects(right)) { @@ -156,6 +155,7 @@ function solve_rects(){ // for (var i = 0; i < rects.length; i++) { // regions.concat(rect[i].regions) // } + // handle when two walls are coplanar // generate floor and ceiling for some regions // generate walls from surviving regions // generate ceiling-walls where ceiling has discontinuity -- cgit v1.2.3-70-g09d2