From fd8a036cac132efbc1ec6d9649bdaecf6694df21 Mon Sep 17 00:00:00 2001 From: videlec Date: Tue, 27 Jun 2023 14:26:56 +0200 Subject: [PATCH 1/7] monotile notebook --- doc/examples/monotile.md | 108 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 doc/examples/monotile.md diff --git a/doc/examples/monotile.md b/doc/examples/monotile.md new file mode 100644 index 000000000..82250761f --- /dev/null +++ b/doc/examples/monotile.md @@ -0,0 +1,108 @@ +--- +jupytext: + formats: ipynb,md:myst + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.14.6 +kernelspec: + display_name: SageMath 9.7 + language: sage + name: sagemath +--- + +# Playing with the monotile + +The monotile is a polygon that tiles the plane by rotation and reflections. Interestingly +one can build two translation surfaces out of it. + +The monotile is the following polygon. +```{code-cell} +from flatsurf import Polygon, MutableOrientedSimilaritySurface + +K = QuadraticField(3) +a = K.gen() + +# build the vectors +l = [(1, 0), (1, 2), (a, 11), (a, 1), (1, 4), (1, 6), (a, 3), + (a, 5), (1, 8), (1, 6), (a, 9), (a, 7), (1, 10), (1, 0)] +vecs = [] +for m, e in l: + v = vector(K, [m * cos(2*pi*e/12), m * sin(2*pi*e/12)]) + vecs.append(v) +p = Polygon(edges=vecs) +``` + +One can build translation surfaces by gluing parallel edges. There is an +ambiguity in doing so because of the horizontal segments. We a surface +`Sbase` where non-ambiguous gluings are performed. +```{code-cell} +from collections import defaultdict +d = defaultdict(list) +for i, e in enumerate(p.edges()): + e.set_immutable() + d[e].append(i) +``` + +```{code-cell} +Sbase = MutableOrientedSimilaritySurface(K) +_ = Sbase.add_polygon(p) +for v in list(d): + if v in d: + indices = d[v] + v_op = -v + v_op.set_immutable() + opposite_indices = d[v_op] + assert len(indices) == len(opposite_indices), (len(indices), len(opposite_indices)) + if len(indices) == 1: + del d[v] + del d[v_op] + Sbase.glue((0, indices[0]), (0, opposite_indices[0])) +``` + +Next we recover the ambiguous edges and build the two possible remaining gluings. +```{code-cell} +assert len(d) == 2 +(i0, j0), (i1, j1) = d.values() +``` + +```{code-cell} +S1 = MutableOrientedSimilaritySurface.from_surface(Sbase) +S1.glue((0, i0), (0, i1)) +S1.glue((0, j0), (0, j1)) +S1.set_immutable() +``` + +```{code-cell} +S2 = MutableOrientedSimilaritySurface.from_surface(Sbase) +S2.glue((0, i0), (0, j1)) +S2.glue((0, j0), (0, i1)) +S2.set_immutable() +``` + +We indeed obtain translation surfaces +```{code-cell} +print(S1.category()) +print(S2.category()) +``` + +And one can compute their genera +```{code-cell} +print(S1.genus(), S2.genus()) +``` + +and strata +```{code-cell} +print(S1.stratum(), S2.stratum()) +``` + +TODO: failure +```{code-cell} +S1.triangulate() +``` + +TODO: failure +```{code-cell} +S2.triangulate() +``` From f05dc1e38ef9c24a7cdda1d52bd40cde84a3cd01 Mon Sep 17 00:00:00 2001 From: videlec Date: Tue, 27 Jun 2023 14:30:01 +0200 Subject: [PATCH 2/7] news entry --- doc/news/monotile.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/news/monotile.rst diff --git a/doc/news/monotile.rst b/doc/news/monotile.rst new file mode 100644 index 000000000..0b1dd61ea --- /dev/null +++ b/doc/news/monotile.rst @@ -0,0 +1,3 @@ +**Added:** + +* monotile notebook example From bd3226bce4507871f348a5d7587b6dba30e485a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Tue, 27 Jun 2023 20:08:32 +0300 Subject: [PATCH 3/7] Update doc/examples/monotile.md --- doc/examples/monotile.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/examples/monotile.md b/doc/examples/monotile.md index 82250761f..1b761c123 100644 --- a/doc/examples/monotile.md +++ b/doc/examples/monotile.md @@ -97,12 +97,8 @@ and strata print(S1.stratum(), S2.stratum()) ``` -TODO: failure ```{code-cell} S1.triangulate() -``` - -TODO: failure ```{code-cell} S2.triangulate() ``` From eb1ddc88ebe750c44cb6bdd71907e33e0a5eb7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20R=C3=BCth?= Date: Tue, 27 Jun 2023 20:09:16 +0300 Subject: [PATCH 4/7] Fix syntax of monotile notebook --- doc/examples/monotile.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/examples/monotile.md b/doc/examples/monotile.md index 1b761c123..64c142b00 100644 --- a/doc/examples/monotile.md +++ b/doc/examples/monotile.md @@ -99,6 +99,8 @@ print(S1.stratum(), S2.stratum()) ```{code-cell} S1.triangulate() +``` + ```{code-cell} S2.triangulate() ``` From 4901aa774a3f186e8c585deeddb424e00d5f3637 Mon Sep 17 00:00:00 2001 From: Vincent Delecroix Date: Wed, 28 Jun 2023 07:51:06 +0200 Subject: [PATCH 5/7] review suggestions - improve the notebook - add it in the documentation index --- doc/examples/monotile.md | 3 ++- doc/index.rst | 1 + doc/news/monotile.rst | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/examples/monotile.md b/doc/examples/monotile.md index 64c142b00..34ea26271 100644 --- a/doc/examples/monotile.md +++ b/doc/examples/monotile.md @@ -32,10 +32,11 @@ for m, e in l: v = vector(K, [m * cos(2*pi*e/12), m * sin(2*pi*e/12)]) vecs.append(v) p = Polygon(edges=vecs) +p.plot() ``` One can build translation surfaces by gluing parallel edges. There is an -ambiguity in doing so because of the horizontal segments. We a surface +ambiguity in doing so because of the horizontal segments. We create a surface `Sbase` where non-ambiguous gluings are performed. ```{code-cell} from collections import defaultdict diff --git a/doc/index.rst b/doc/index.rst index 0ca537eb0..409f35d0e 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -58,6 +58,7 @@ Demos of some of the capabilities of sage-flatsurf: examples/straight_line_flow examples/warwick-2017 examples/boshernitzan_conjecture + examples/monotile These examples can also be explored interactively by clicking |binder|_. The interactive session might take a moment to start. Once ready, press Shift + diff --git a/doc/news/monotile.rst b/doc/news/monotile.rst index 0b1dd61ea..5bc3af6e6 100644 --- a/doc/news/monotile.rst +++ b/doc/news/monotile.rst @@ -1,3 +1,3 @@ **Added:** -* monotile notebook example +* Added a monotile notebook example to the examples section of the documentation. From bae70cd171c59725572534b87a596d07f4cf9234 Mon Sep 17 00:00:00 2001 From: videlec Date: Wed, 28 Jun 2023 13:32:30 +0200 Subject: [PATCH 6/7] linting monotile.md --- doc/examples/monotile.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/doc/examples/monotile.md b/doc/examples/monotile.md index 34ea26271..46b794563 100644 --- a/doc/examples/monotile.md +++ b/doc/examples/monotile.md @@ -25,11 +25,25 @@ K = QuadraticField(3) a = K.gen() # build the vectors -l = [(1, 0), (1, 2), (a, 11), (a, 1), (1, 4), (1, 6), (a, 3), - (a, 5), (1, 8), (1, 6), (a, 9), (a, 7), (1, 10), (1, 0)] +l = [ + (1, 0), + (1, 2), + (a, 11), + (a, 1), + (1, 4), + (1, 6), + (a, 3), + (a, 5), + (1, 8), + (1, 6), + (a, 9), + (a, 7), + (1, 10), + (1, 0) +] vecs = [] for m, e in l: - v = vector(K, [m * cos(2*pi*e/12), m * sin(2*pi*e/12)]) + v = vector(K, [m * cos(2 * pi * e / 12), m * sin(2 * pi * e / 12)]) vecs.append(v) p = Polygon(edges=vecs) p.plot() @@ -38,8 +52,10 @@ p.plot() One can build translation surfaces by gluing parallel edges. There is an ambiguity in doing so because of the horizontal segments. We create a surface `Sbase` where non-ambiguous gluings are performed. + ```{code-cell} from collections import defaultdict + d = defaultdict(list) for i, e in enumerate(p.edges()): e.set_immutable() @@ -55,7 +71,7 @@ for v in list(d): v_op = -v v_op.set_immutable() opposite_indices = d[v_op] - assert len(indices) == len(opposite_indices), (len(indices), len(opposite_indices)) + assert len(indices) == len(opposite_indices) if len(indices) == 1: del d[v] del d[v_op] @@ -63,6 +79,7 @@ for v in list(d): ``` Next we recover the ambiguous edges and build the two possible remaining gluings. + ```{code-cell} assert len(d) == 2 (i0, j0), (i1, j1) = d.values() @@ -89,11 +106,13 @@ print(S2.category()) ``` And one can compute their genera + ```{code-cell} print(S1.genus(), S2.genus()) ``` and strata + ```{code-cell} print(S1.stratum(), S2.stratum()) ``` From f1fdd8bc3ecd1af1275ef821554e0466f89e3529 Mon Sep 17 00:00:00 2001 From: videlec Date: Wed, 28 Jun 2023 13:54:16 +0200 Subject: [PATCH 7/7] more linting --- doc/examples/monotile.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/examples/monotile.md b/doc/examples/monotile.md index 46b794563..f2c610a38 100644 --- a/doc/examples/monotile.md +++ b/doc/examples/monotile.md @@ -18,6 +18,7 @@ The monotile is a polygon that tiles the plane by rotation and reflections. Inte one can build two translation surfaces out of it. The monotile is the following polygon. + ```{code-cell} from flatsurf import Polygon, MutableOrientedSimilaritySurface @@ -39,7 +40,7 @@ l = [ (a, 9), (a, 7), (1, 10), - (1, 0) + (1, 0), ] vecs = [] for m, e in l: @@ -100,6 +101,7 @@ S2.set_immutable() ``` We indeed obtain translation surfaces + ```{code-cell} print(S1.category()) print(S2.category())