Last active
April 22, 2018 04:16
-
-
Save mdonahoe/d83350c491e6e10a5d8c70f90b7807b9 to your computer and use it in GitHub Desktop.
Hilbert curve iteration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import * | |
def hilbert(pts): | |
s = 1 + (pts[-1][0] - pts[0][0]) / 2 | |
return ( [(y-s, x-s) for x,y in pts] | |
+ [(x-s, y+s) for x,y in pts] | |
+ [(x+s, y+s) for x,y in pts] | |
+ [(s-y,-x-s) for x,y in pts] ) | |
pts = [(0, 0)] | |
for i in range(8): | |
pts = hilbert(pts) | |
plot(*zip(*pts)) | |
show() |
Author
mdonahoe
commented
Apr 22, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment