X-Git-Url: http://git.tomasm.cz/imago.git/blobdiff_plain/e4044c7515289bb999ee98698abbe09aa6e4b517..bc8264a583025d7be3e3238aa40d4950050f7fcf:/new_geometry.py diff --git a/new_geometry.py b/new_geometry.py index 3727056..ab62210 100644 --- a/new_geometry.py +++ b/new_geometry.py @@ -27,8 +27,7 @@ def fill(l1, l2, lh, n): return (fill(l1, lm, (lh1, lhc), n / 2) + [lm] + fill(lm, l2, (lhc, lh2), n / 2)) - elif n == 2: - # TODO fine tune this + elif n == 2 or n == 8: nlt = intersection((lh1, l21), (l11, l22)) nlb = intersection((lh1, l22), (l12, l21)) nrt = intersection((lh2, l11), (l12, l21)) @@ -37,8 +36,31 @@ def fill(l1, l2, lh, n): intersection((l12, l22), (nlt, nlb))) nr = (intersection((l11, l21), (nrt, nrb)), intersection((l12, l22), (nrt, nrb))) - return [nl, nr] + if n == 2: + return [nl, nr] + elif n == 8: + return (fill(l1, nl, + (intersection(l1, lh), + intersection(nl, lh)), 2) + + [nl] + + fill(nl, nr, + (intersection(nl, lh), + intersection(nr, lh)), 2) + + [nr] + + fill(nr, l2, + (intersection(nr, lh), + intersection(l2, lh)), 2)) +def expand_right(grid, middle): + return expand(grid[-2], grid[-1], + (intersection(middle, grid[-2]), + (intersection(middle, grid[-1])))) + +def expand_left(grid, middle): + return expand(grid[1], grid[0], + (intersection(middle, grid[1]), + (intersection(middle, grid[0])))) + def expand(l1, l2, lh): l11, l12 = l1 l21, l22 = l2