A tour in the wonderland of math with python

Aperiodic Tilings using de Bruijn's Algebraic Approach

This script draws rhombus tilings using de Bruijn’s dual grid approach as descripted in his paper

Algebraic theory of Penrose’s non-periodic tilings of the plane.

There is also a clean introduction to this method in the book

Aperiodic order, Volume 1: A mathematical invitation. Encyclopedia of mathematics and its applications, vol 149.

These tilings are called “aperiodic” in that

  1. They have no translational symmetry.
  2. Any finite region (patch) in a tiling appears infinitely many times in that tiling.


  1. numpy and cairocffi.
  2. The free raytracer POV-Ray (optional).


  1. A random pentagrid pattern:

  2. The Ammann-Beenker pattern (put DIMENSION=4 in the code):

  3. A rhombus tiling using 10 grids:

  4. A tiling exported to POV-Ray:


Run python to generate a 2D image and the data of the tiling, then go to the folder /povray/ and run scene.pov with POV-Ray.

There are two parameters that completely determine the tiling: DIMENSION and SHIFTS. For example to draw the classic Penrose tiling DIMENSION=5 and SHIFTS can be any 5-tuple that sums to an integer like (0.1, 0.2, 0.3, -0.2, -0.4), but not the degenerate case like (0, 0, 0, 0, 0). If SHIFTS=(0.5, 0.5, 0.5, 0.5, 0.5) then one gets the “anti-penrose” pattern. For DIMENSION=4 one gets the famous “Ammann-Beenker” tiling.