While in the stall attending to some personal business today, I read the graffiti as usual. One particular one is a pretty poor attempt at an Apollonian gasket. Somehow from there I started wondering if it is possible to construct Apollonian gaskets with five-fold symmetry (in particular, I was seeing if I can draw a gasket such that instead of having hyperbolic triangles left over, we have all hyperbolic pentagons).
The question can be (sort of) reduced to one in planar graphs, in particular the tiling of a pentagon by smaller pentagons. Once I see this, I realized that this allows a way to construct an analogue to the Sierpinski gasket using pentagons.
Here's how I drew it: I first discovered the PERL module PostScript::Simple (interested parties can search for thatn on CPAN). Then I wrote this simple (ugly and inelegant, probably with lots of inefficiencies) script with a single recursion:
use strict;
use PostScript::Simple;
my $p = new PostScript::Simple(colour => 1, eps => 1, units => "pt", xsize => 1000, ysize => 1000);
my @pa = (500,100);
my @pb = (200,300);
my @pc = (325,650);
my @pd = (675,650);
my @pe = (800,300);
$p->polygon( @pa, @pb, @pc, @pd, @pe, @pa);
iterDrawPenta(8,@pa,@pb,@pc,@pd,@pe);
$p->output("test.eps");
sub iterDrawPenta {
if ($_[0] == 0){ return; }
my @points = @_[1..10];
my @points2 = @_[3..10,1,2];
my @points3 = @_[5..10,1..4];
my @points4 = @_[9,10,1..8];
my @outside;
my @inside;
for (my $k = 0; $k < 5; $k ++){
push(@outside, ($points[2*$k] + $points2[2*$k])/2);
push(@outside, ($points[2*$k+1] + $points2[2*$k+1])/2);
push(@inside, ((2*$points[2*$k] + $points4[2*$k])/3 + (2*$points2[2*$k] + $points3[2*$k])/3)/2);
push(@inside, ((2*$points[2*$k+1] + $points4[2*$k+1])/3 + (2*$points2[2*$k+1] + $points3[2*$k+1])/3)/2);
$p->line(@outside[2*$k,2*$k+1],@inside[2*$k,2*$k+1]);
}
$p->polygon(@inside, @inside[0,1]);
iterDrawPenta( $_[0] - 1, @points[0,1], @outside[0,1], @inside[0,1], @inside[8,9], @outside[8,9]);
iterDrawPenta( $_[0] - 1, @points[2,3], @outside[2,3], @inside[2,3], @inside[0,1], @outside[0,1]);
iterDrawPenta( $_[0] - 1, @points[4,5], @outside[4,5], @inside[4,5], @inside[2,3], @outside[2,3]);
iterDrawPenta( $_[0] - 1, @points[6,7], @outside[6,7], @inside[6,7], @inside[4,5], @outside[4,5]);
iterDrawPenta( $_[0] - 1, @points[8,9], @outside[8,9], @inside[8,9], @inside[6,7], @outside[6,7]);
}
The script uses the PostScript::Simple module and starts by initiating an eps canvas. The five arrays pa,pb,pc,pd,pe are the initial starting coordinates for the pentagon. The main drawing is done by the sub-routine iterDrawPenta which divides the input-pentagon into 6 sub-pentagons, and recursively calls itself, inputting the 5 outer sub-pentagons. The leading parameter of iterDrawPenta keeps track of the level of recursion.
The figure above was drawn using 8 levels of recursion, which produced a 79 megabyte postscript file, which I then converted to a much smaller png image.