#! /usr/bin/perl -w # Copyright (c) 1999 Greg Bacon. # This program is free software. You may distribute it or modify # it (perhaps both) under the terms of the Artistic License that # comes with the Perl Kit. use strict; use constant PI => 4 * atan2 1, 1; use Tk; # width (and height) of the window my $WIDTH = 420; # radius of the circle on which we enscribe the triangle my $RADIUS = 200; # coordinates of the centroid my $cx = $WIDTH / 2; my $cy = $WIDTH / 2 + 25; # radius of the vertices my $R = 10; my $mw = MainWindow->new; $mw->title('The Fano Plane'); $mw->iconname('Fano'); my $c = $mw->Canvas( -width => $WIDTH, -height => $WIDTH, -background => 'white', )->pack; my @V; my $theta; my $x; my $y; # draw the outer vertices for (my $i = 0; $i < 3; $i++) { $theta = $i * 2*PI/3 - PI/2; $x = $RADIUS * cos($theta) + $cx; $y = $RADIUS * sin($theta) + $cy; $c->createOval( $x+$R, $y+$R => $x-$R, $y-$R, -fill => 'black', ); $V[$i] = [ $x, $y ]; } # draw the vertices on the outer edges for (1 .. 3) { my($one,$two,$other) = @V; my($x1,$y1) = @$one; my($x2,$y2) = @$two; $x = ($x1 + $x2) / 2; $y = ($y1 + $y2) / 2; $c->createOval( $x+$R, $y+$R => $x-$R, $y-$R, -fill => 'black', ); $c->createLine( $x1, $y1 => $x2, $y2, -fill => 'black', -width => 2, ); $c->createLine( $x, $y => @$other, -fill => 'black', -width => 2, ); @V = ($two, $other, $one); } # draw the vertex in the center $c->createOval( $cx+$R, $cy+$R => $cx-$R, $cy-$R, -fill => 'black', ); # draw the circular hyperedge my $r = $RADIUS / 2; $c->createOval( $cx+$r, $cy+$r, $cx-$r, $cy-$r, -outline => 'black', -width => 2, ); MainLoop;