No description
Find a file
2014-07-27 17:54:49 +02:00
.gitignore ignore tmp/out files 2014-05-21 13:44:37 +02:00
ants.py Move tour, LOG and LOGN in utils, add vertices_from_set 2014-03-25 20:58:52 +01:00
geometry.py add epsilon to collinearity test, plus a demo 2014-06-02 08:42:57 +02:00
graph.py refactor load/save functions 2014-05-21 13:42:23 +02:00
hull.py Adds a geometry module with a segment_intersection function 2014-05-17 16:02:01 +02:00
lindenmayer.py adds a separated module for plotting 2014-03-20 23:29:41 +01:00
penrose_tsp.py use a L-system to generate a penrose tiling and save it in the TSPlib format 2011-07-24 08:06:06 +02:00
quadtree.py First implementation of indexed quad trees 2014-07-27 17:54:49 +02:00
README.md README update with Penrose Voronoi graph 2014-05-17 16:28:08 +02:00
run_all.py save images with the depth in the filename 2014-06-02 16:09:47 +02:00
shortpath.py Adds a geometry module with a segment_intersection function 2014-05-17 16:02:01 +02:00
test_tsp.py test tsplib import/export on a simple square 2011-07-24 08:04:29 +02:00
triangulation.py clean triangulation subfunctions 2014-06-02 08:44:12 +02:00
tsplib.py bugfix tsplib indexing 2014-03-20 23:32:16 +01:00
uberplot.py Adds the voronoi module and demo 2014-05-13 15:27:25 +02:00
utils.py misc bugfixes 2014-05-26 11:36:16 +02:00
voronoi.py bugfix voronoi's dual: yield in the loop to test all edges candidates 2014-06-02 08:42:03 +02:00

Übergeekism

This is an attempt at using as many as possible cool computer science stuff to produce a single image.

Algorithms may not be implemented in the most efficient manner, as the aim is to have elegant and simple code for educational purpose.

Until now, the following algorithms/data structure/concepts are used:

  • the (logo) turtle,
  • Lindenmayer systems,
  • Penrose tiling,
  • travelling salesman problem,
  • ant colony algorithm,
  • A* shortest path,
  • circumcircle of a triangle,
  • Delaunay triangulation,
  • Bowyer-Watson algorithm,
  • lines and segments intersections,
  • graph (adjacency list, adjacency matrix),
  • hash table.

And the following ones are implemented but not used:

  • convex hull,
  • Chan's algorithm,

The current code is written in Python.

Penrose tiling drawing

The main shape visible on the image is a Penrose tiling (type P3), which is a non-periodic tiling with an absurd level of coolness.

The edges are recursively built with a Lindenmayer system. Yes, it is capable of building a Penrose tiling if you know which grammar to use. Yes, this is insanely cool.

The Lindenamyer system works by drawing edges one after another, we thus use a (LOGO) turtle to draw them.

Because the L-system grammar is not very efficient to build the tiling, we insert edges in a data structure that contains an unordered collection of unique element: a hash table.

Travelling Salesman Problem

The Penrose tiling segments defines a graph, which connects a set of vertices with a set of edges. We can consider the vertices as cities and edges as roads between them.

Now we want to find the shortest possible route that visits each city exactly once and returns to the origin city. This is the Travelling Salesman Problem. We use an Ant Colony Optimization algorithm to (try) to solve it.

Because each city is not connected to every other cities, we need to find the shortest path between two cities. This is done with the help of the famously cool A-star algorithm.

The ant colony algorithm output a path that connect every cities, which is drawn on the image, but it also stores a so-called pheromones matrix, which can be drawn as edges with variable transparency/width.

Penrose tiling

Because the L-system draws the Penrose tiling segments by segments, we need to compute how each segment is related to the diamonds to rebuild the tiling corresponding to all those edges.

Fortunately, computing a Delaunay triangulation of the Penrose vertices brings back a triangular subgraph of the Penrose graph (how cool is that!?) and stores plain shapes (triangles) instead of unordered segments. This is done thanks to the Bowyer-Watson algorithm.

But this triangulation contains edges that link the set of exterior vertices, which are not in the Penrose tiling. This is solved by computing the convex hull, with the Chan's algorithm, and removing the triangles that contains those edges from the triangulation removing obtuse triangles.

Penrose graph

We now want to connect each diamond to its neighbour, so as to build the Penrose graph itself. One way to do that is to compute the Voronoï diagram of the previous Delaunay triangulation. But we really want the Voronoï diagram of the Penrose tiling (with diamonds), not its triangulation (with, well, triangles).

We thus need to merge each edge of the Voronoï graph that do not cross a segment of the Penrose tiling into a single node, while preserving its neighbours. We thus need to compute segments intersection (which does not seems so cool but really is) and find a way to reduce the graph.

TODO

More coolness:

  • quad trees may be useful somewhere to query neighbors points?,
  • Draw the neighborhood with splines across the center of diamonds segments,
  • Run a cellular automata on this Penrose tiling,
  • Draw a planner on it.

Maybe even more coolness?

  • percolation theory?

Improvements:

  • Use a triangular matrix for pheromones in ACO.