{
"nbformat_minor": 2,
"nbformat": 4,
"cells": [
{
"source": [
"$$\n",
"\\def\\CC{\\bf C}\n",
"\\def\\QQ{\\bf Q}\n",
"\\def\\RR{\\bf R}\n",
"\\def\\ZZ{\\bf Z}\n",
"\\def\\NN{\\bf N}\n",
"$$\n",
"# Drawing the Penrose tiling with substitutions\n",
"\n",
"The aim of this tutorial is to draw the Penrose tiling by applying a substitution process.\n",
"\n",
"## Description\n",
"\n",
"We use two substitution/subdivision rules on two isosceles triangles as in the picture, with ratios $BA/PA=BA/BQ=\\frac{1+\\sqrt{5}}{2}$ :\n",
"\n",
"![image](./tikz_penrose_gimp.png)\n",
"\n",
"The Penrose tiling is obtained by iterating this substitution from the red triangle. Be careful about the orientation of the triangles!\n",
"\n",
"(note that the image is hosted on my machine, you should download the image from the server if you want to have it back at home)\n",
"\n",
"## Data structure\n",
"\n",
"A point is a complex number. We decide to work with numerical complex numbers, they belong to `CDF`.\n",
"\n",
"A colored triangle is a quadruple `(color, A,B,C)`, where `color` is one of the strings `'red'`, `'blue'` and `A`, `B`, `C` are points.\n",
"\n",
"A tiling is a list of colored triangles.\n",
"\n",
"## Writing code\n",
"\n",
"Define the `golden_ratio` as a numerical approximation of $\\frac{1+\\sqrt{5}}{2}$ :"
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"Define the red and blue base triangles (such that `AB=1`):"
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"Write a function `plot_triangle` that plots a given colored triangle:"
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"Write a function `subdivide` that subdivides a triangle according to the rules given in the description:"
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"Write a function `iteration` that, given a tiling and an integer `n`, returns the tiling obtained by iterating the substitution `n` times:"
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"Write a function `plot_tiling` that plots a given tiling:"
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"Draw a big patch of the Penrose tiling (about 8 or 9 iterations of a triangle):"
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"To see the picture in more details, save the image into the `.svg` vectorial format and edit it with `inkscape`."
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"You can also adapt the code so that the choice of colors can be decided during the plotting (with a `colors` option for the `plot_triangle` and `plot_tiling` functions). For this, you can set the abstract color to be the integers `0` or `1`."
],
"cell_type": "markdown",
"metadata": {}
},
{
"execution_count": null,
"cell_type": "code",
"source": [
"# edit here"
],
"outputs": [],
"metadata": {}
},
{
"source": [
"> **note**\n",
">\n",
"> This worksheet is inspired by [this webpage](http://preshing.com/20110831/penrose-tiling-explained) and \n",
"> was written by Thierry Monteil.\n",
">"
],
"cell_type": "markdown",
"metadata": {}
}
],
"metadata": {
"kernelspec": {
"display_name": "sagemath",
"name": "sagemath"
}
}
}