Add generator and call it
This commit is contained in:
parent
7a46bc6fae
commit
4035ed4e2f
|
@ -43,3 +43,19 @@ def hilbert(center, x, y):
|
||||||
hilbert(center + x - y, x, y)
|
hilbert(center + x - y, x, y)
|
||||||
hilbert(center + x + y, ~x, ~y)
|
hilbert(center + x + y, ~x, ~y)
|
||||||
|
|
||||||
|
|
||||||
|
def hilbertgenerator(center, x, y):
|
||||||
|
if abs(x) < 1:
|
||||||
|
yield center
|
||||||
|
else:
|
||||||
|
x /= 2
|
||||||
|
y /= 2
|
||||||
|
for r in hilbertgenerator(center - x + y, -~x, -~y):
|
||||||
|
yield r
|
||||||
|
for r in hilbertgenerator(center - x - y, x, y):
|
||||||
|
yield r
|
||||||
|
for r in hilbertgenerator(center + x - y, x, y):
|
||||||
|
yield r
|
||||||
|
for r in hilbertgenerator(center + x + y, ~x, ~y):
|
||||||
|
yield r
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
from hilbertgenerator import Vector, hilbertgenerator
|
||||||
|
|
||||||
|
n = 8
|
||||||
|
for r in hilbertgenerator(Vector(n, n), Vector(n, 0), Vector(0,n)):
|
||||||
|
print(r)
|
Loading…
Reference in New Issue