Created
June 16, 2020 19:43
-
-
Save rmloveland/43d11c2107139cd68a28f64cde46aff6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(define (hilbert order width) | |
(let loop ((count 0) | |
(shape (h0 width))) | |
(if (= count order) | |
shape | |
(let* ((next-shape (shrink-shape shape 0.5)) | |
(upper-left (reflect-shape (rotate-shape next-shape (* 3.14159 1.5)))) | |
(upper-right (translate-shape next-shape 'east width)) | |
(lower-left (translate-shape next-shape 'south width)) | |
(lower-left* (reflect-shape (rotate-shape lower-left (* 3.14159 .5)))) | |
(lower-right (translate-shape next-shape 'southeast width))) | |
(loop (+ count 1) | |
(merge-shapes upper-left upper-right lower-right lower-left*)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment