diff --git a/auxiliary/hatgen.c b/auxiliary/hatgen.c index 30242c9..84ced0f 100644 --- a/auxiliary/hatgen.c +++ b/auxiliary/hatgen.c @@ -1330,6 +1330,26 @@ static void draw_hats_svg(const Hat *hats, size_t n, printf("\n"); } +static void draw_hats_python(const Hat *hats, size_t n) +{ + size_t i, j; + + printf("def hats(hat):\n"); + for (i = 0; i < n; i++) { + const Hat *hat = &hats[i]; + Point vertices[HAT_NVERT]; + size_t nv = hat_vertices(*hat, vertices); + + printf(" hat('%c', %d, None, [", + "HTPF"[hat->parent->type], hat->index); + for (j = 0; j < nv; j++) { + Point v = vertices[j]; + printf("%s(%d,%d)", j ? ", " : "", (v.x * 2 + v.y) / 3, v.y); + } + printf("])\n"); + } +} + typedef enum KiteStep { KS_LEFT, KS_RIGHT, KS_F_LEFT, KS_F_RIGHT } KiteStep; static inline Point kite_step(Point k, KiteStep step) @@ -1459,6 +1479,31 @@ int main(int argc, char **argv) return 0; } + if (argv[1][0] == 'P' && argv[1][1] && strchr("HTPF", argv[1][1])) { + int niter = atoi(argv[1] + 2); + MetatileType type = (argv[1][1] == 'H' ? MT_H : + argv[1][1] == 'T' ? MT_T : + argv[1][1] == 'P' ? MT_P : MT_F); + MetatileSet *tiles = metatile_initial_set(type); + + while (niter-- > 0) { + MetatileSet *t2 = metatile_set_expand(tiles); + metatile_free_set(tiles); + tiles = t2; + } + + { + size_t nh; + Hat *h = metatile_set_to_hats(tiles, &nh, NULL); + draw_hats_python(h, nh); + sfree(h); + } + + metatile_free_set(tiles); + + return 0; + } + if (!strcmp(argv[1], "--tables")) { size_t i, j, k; diff --git a/hat.c b/hat.c index dbb8f41..176d1f0 100644 --- a/hat.c +++ b/hat.c @@ -2,10 +2,17 @@ * Code to generate patches of the aperiodic 'hat' tiling discovered * in 2023. * - * auxiliary/doc/hats.html contains an explanation of the basic ideas - * of this algorithm, which can't really be put in a source file - * because it just has too many complicated diagrams. So read that - * first, because the comments in here will refer to it. + * This uses the 'combinatorial coordinates' system documented in my + * public article + * https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/aperiodic-tilings/ + * + * The internal document auxiliary/doc/hats.html also contains an + * explanation of the basic ideas of this algorithm (less polished but + * containing more detail). + * + * Neither of those documents can really be put in a source file, + * because they just have too many complicated diagrams. So read at + * least one of those first; the comments in here will refer to it. * * Discoverers' website: https://cs.uwaterloo.ca/~csk/hat/ * Preprint of paper: https://arxiv.org/abs/2303.10798 diff --git a/penrose.c b/penrose.c index 4d2a740..1c45ddb 100644 --- a/penrose.c +++ b/penrose.c @@ -2,9 +2,10 @@ * * Penrose tile generator. * - * Uses half-tile technique outlined on: + * Works by choosing a small patch from a recursively expanded large + * region of tiling, using one of the two algorithms described at * - * http://tartarus.org/simon/20110412-penrose/penrose.xhtml + * https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/aperiodic-tilings/ */ #include