#!/opt/local/bin/perl # change path to fit your system # usage: $ perl infinitile.pl # can generate SVG files containing puzzle pieces in a tile # Copyright (C) 2010 Robert Flannery # version 1.0 # Thu Jul 29 06:14:26 PDT 2010 # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # I used regular_polygon.pl by GustavB to create a decagon. # http://commons.wikimedia.org/wiki/User:Gustavb/regular_polygon.pl # Daud Sutton explains how to use a few pieces to create an indefinitely large # puzzle, inspired by Islamic Design, which is the name of his book. # http://www.powells.costarm/biblio?isbn=9780802716354 # Squiggle is what I've been using to convert SVG to PNG # http://xmlgraphics.apache.org/batik/tools/browser.html # points @star = (); $#star = 19; # array length of 20 $star_length = $#star + 1; $pindex = 0; # point index # Presentation parameters $stroke = 0.1; $draw_border = 1; $border_color = "#777"; $star_color = "#AAA"; $kite_color = "#887"; $pentagon_color = "#444"; $bottle_color = "#755"; $doublepentagon_color = "#666"; # Constants $pi = 3.14159265358979323846264338327950288419717; # Derived measures $d = 2*$pi/10; $a = ($pi - $d) / 2; $radius = 36; $centerX = 0; $centerY = 0; #default $dim = 800; $vdim = 800; $Elmer = '' . "\n\n"; # definitions for SVG file for($v=$a; $v <= 2*$pi+$a-$d; $v+=$d) { $x = $centerX + $radius*cos($v); $y = $centerY + $radius*sin($v); $star[$pindex] = [$x, $y]; $pindex += 2; # 2 increment if($pindex > $#star) { $pindex = $pindex % ($star_length); # modulo } } for($pindex=1; $pindex<$star_length; $pindex += 2) #$pindex is calculated value { $p1_index = $pindex + 1; if($p1_index > $#star) { $p1_index = $p1_index % $star_length; # modulo } $p1ref = $star[$p1_index]; $p2_index = $p1_index + 4; if($p2_index > $#star) { $p2_index = $p2_index % $star_length; # modulo } $p2ref = $star[$p2_index]; $line1ref = [$p1ref, $p2ref]; $p3_index = $pindex + 3; if($p3_index > $#star) { $p3_index = $p3_index % $star_length; # modulo } $p3ref = $star[$p3_index]; $p4_index = $p3_index + 4; if($p4_index > $#star) { $p4_index = $p4_index % $star_length; # modulo } $p4ref = $star[$p4_index]; $line2ref = [$p3ref, $p4ref]; $pointref = find_intersection_point( [$line1ref, $line2ref] ); ($xi, $yi) = @{$pointref}; $inter_index = $pindex + 4; if($inter_index > $#star) { $inter_index = $inter_index % $star_length; # modulo } $star[$inter_index] = [$xi, $yi]; } define_pieces( [ @star ], "star", "$star_color" ); ($star_0x, $star_0y) = @{ $star[0] }; ($star_1x, $star_1y) = @{ $star[1] }; ($star_2x, $star_2y) = @{ $star[2] }; ($star_3x, $star_3y) = @{ $star[3] }; ($star_4x, $star_4y) = @{ $star[4] }; ($star_5x, $star_5y) = @{ $star[5] }; ($star_6x, $star_6y) = @{ $star[6] }; ($star_7x, $star_7y) = @{ $star[7] }; ($star_8x, $star_8y) = @{ $star[8] }; ($star_9x, $star_9y) = @{ $star[9] }; ($star_10x, $star_10y) = @{ $star[10] }; ($star_11x, $star_11y) = @{ $star[11] }; ($star_12x, $star_12y) = @{ $star[12] }; ($star_13x, $star_13y) = @{ $star[13] }; ($star_14x, $star_14y) = @{ $star[14] }; ($star_15x, $star_15y) = @{ $star[15] }; ($star_16x, $star_16y) = @{ $star[16] }; ($star_17x, $star_17y) = @{ $star[17] }; ($star_18x, $star_18y) = @{ $star[18] }; ($star_19x, $star_19y) = @{ $star[19] }; @half_star = (); for($pindex=1; $pindex < 12; $pindex++) { push @half_star, $star[$pindex]; } $old_draw_border = $draw_border; $draw_border = 0; define_pieces( [ @half_star ], "half_star_core", "$star_color" ); $draw_border = $old_draw_border; $Elmer = $Elmer . '' . "\n"; # draw needed lines $Elmer = $Elmer . '' . "\n"; if($draw_border == 1) { $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; } $Elmer = $Elmer . '' . "\n\n"; @rising_star = (); for($pindex=1; $pindex < 12; $pindex++) { $star_index = $pindex + 5; $star_index = $star_index % $star_length; # modulo push @rising_star, $star[$star_index]; } $old_draw_border = $draw_border; $draw_border = 0; define_pieces( [ @rising_star ], "rising_star", "$star_color" ); $draw_border = $old_draw_border; ######### additional points $p1ref = $star[9]; $p2ref = $star[10]; $p3ref = $star[12]; $p4ref = $star[13]; $line1ref = [$p1ref, $p2ref]; $line2ref = [$p3ref, $p4ref]; $top_point = find_intersection_point( [$line1ref, $line2ref] ); ($topX, $topY) = @{ $top_point }; $p1ref = $star[2]; $p2ref = $star[3]; $p3ref = $star[0]; $p4ref = $star[19]; $line1ref = [$p1ref, $p2ref]; $line2ref = [$p3ref, $p4ref]; $bottom_point = find_intersection_point( [$line1ref, $line2ref] ); ($bottomX, $bottomY) = @{ $bottom_point }; @k_star = (); # 10 k_star points for($pindex=1; $pindex<$star_length; $pindex += 2) #$pindex is calculated value { $p1ref = $star[$pindex]; $pindex2 = $pindex + 1; if($pindex2 > $#star) { $pindex2 = $pindex2 % $star_length; # modulo } $p2ref = $star[$pindex2]; $pindex3 = $pindex + 3; if($pindex3 > $#star) { $pindex3 = $pindex3 % $star_length; # modulo } $p3ref = $star[$pindex3]; $pindex4 = $pindex + 4; if($pindex4 > $#star) { $pindex4 = $pindex4 % $star_length; # modulo } $p4ref = $star[$pindex4]; $line1ref = [$p1ref, $p2ref]; $line2ref = [$p3ref, $p4ref]; $point_point = find_intersection_point( [$line1ref, $line2ref] ); push @k_star, $point_point; } ($k_star_0x, $k_star_0y) = @{ $k_star[0] }; ($k_star_1x, $k_star_1y) = @{ $k_star[1] }; ($k_star_2x, $k_star_2y) = @{ $k_star[2] }; ($k_star_3x, $k_star_3y) = @{ $k_star[3] }; ($k_star_4x, $k_star_4y) = @{ $k_star[4] }; ($k_star_5x, $k_star_5y) = @{ $k_star[5] }; ($k_star_6x, $k_star_6y) = @{ $k_star[6] }; ($k_star_7x, $k_star_7y) = @{ $k_star[7] }; ($k_star_8x, $k_star_8y) = @{ $k_star[8] }; ($k_star_9x, $k_star_9y) = @{ $k_star[9] }; @long_star = (); # 10 long_star points for($pindex=1; $pindex<$star_length; $pindex += 2) #$pindex is calculated value { $p1ref = $star[$pindex]; $pindex2 = $pindex + 2; if($pindex2 > $#star) { $pindex2 = $pindex2 % $star_length; # modulo } $p2ref = $star[$pindex2]; $pindex8 = $pindex + 8; if($pindex8 > $#star) { $pindex8 = $pindex8 % $star_length; # modulo } $p3ref = $star[$pindex8]; $pindex10 = $pindex + 10; if($pindex10 > $#star) { $pindex10 = $pindex10 % $star_length; # modulo } $p4ref = $star[$pindex10]; $line1ref = [$p1ref, $p2ref]; $line2ref = [$p3ref, $p4ref]; $point_point = find_intersection_point( [$line1ref, $line2ref] ); ($pointX, $pointY) = @{$point_point}; push @long_star, $point_point; } ($long_star_0x, $long_star_0y) = @{ $long_star[0] }; ($long_star_1x, $long_star_1y) = @{ $long_star[1] }; ($long_star_2x, $long_star_2y) = @{ $long_star[2] }; ($long_star_3x, $long_star_3y) = @{ $long_star[3] }; ($long_star_4x, $long_star_4y) = @{ $long_star[4] }; ($long_star_5x, $long_star_5y) = @{ $long_star[5] }; ($long_star_6x, $long_star_6y) = @{ $long_star[6] }; ($long_star_7x, $long_star_7y) = @{ $long_star[7] }; ($long_star_8x, $long_star_8y) = @{ $long_star[8] }; ($long_star_9x, $long_star_9y) = @{ $long_star[9] }; # kite @kite = (); #empty array $pindex=1; $p1_index = $pindex + 1; if($p1_index > $#star) { $p1_index = $p1_index % $star_length; # modulo } $p1ref = $star[$p1_index]; $p2_index = $p1_index + 3; if($p2_index > $#star) { $p2_index = $p2_index % $star_length; # modulo } $p2ref = $star[$p2_index]; $line1ref = [$p1ref, $p2ref]; $p3_index = $pindex + 19; if($p3_index > $#star) { $p3_index = $p3_index % $star_length; # modulo } $p3ref = $star[$p3_index]; $p4_index = $p3_index + 17; if($p4_index > $#star) { $p4_index = $p4_index % $star_length; # modulo } $p4ref = $star[$p4_index]; $line2ref = [$p3ref, $p4ref]; $pointref = find_intersection_point( [$line1ref, $line2ref] ); ($xi, $yi) = @{ $pointref }; $p1_index = $pindex + 19; if($p1_index > $#star) { $p1_index = $p1_index % $star_length; # modulo } $trough_index = $p1_index + 1; if($trough_index > $#star) { $trough_index = $trough_index % $star_length; # modulo } $point_four_index = $p1_index + 2; if($point_four_index > $#star) { $point_four_index = $point_four_index % $star_length; # modulo } push @kite, $pointref; push @kite, $star[$p1_index]; push @kite, $star[$trough_index]; push @kite, $star[$point_four_index]; define_pieces( [ @kite ], "kite", "$kite_color" ); ($kite_0x, $kite_0y) = @{ $kite[0] }; ($kite_1x, $kite_1y) = @{ $kite[1] }; ($kite_2x, $kite_2y) = @{ $kite[2] }; ($kite_3x, $kite_3y) = @{ $kite[3] }; @half_kite = (); for($pindex=0; $pindex < 3; $pindex++) { push @half_kite, $kite[$pindex]; } $old_draw_border = $draw_border; $draw_border = 0; define_pieces( [ @half_kite ], "half_kite_core", "$kite_color" ); $draw_border = $old_draw_border; $Elmer = $Elmer . '' . "\n"; # add needed lines $Elmer = $Elmer . '' . "\n"; if($draw_border == 1) { $Elmer = $Elmer . '' . "\n"; } $Elmer = $Elmer . '' . "\n\n"; # pentagon @pentagon = (); ($star_9x, $star_9y) = @{ $star[9] }; ($star_3x, $star_3y) = @{ $star[3] }; ($star_11x, $star_11y) = @{ $star[11] }; ($star_17x, $star_17y) = @{ $star[17] }; ($star_7x, $star_7y) = @{ $star[7] }; ($star_13x, $star_13y) = @{ $star[13] }; $pentagon[0] = [$star_9x, $star_9y]; $pentagon[1] = [$star_11x, $star_11y]; $pentagon[2] = find_intersection_point( [ [ [$star_3x, $star_3y], [$star_13x, $star_13y] ], [ [$star_11x, $star_11y], [$star_17x, $star_17y] ] ] ); $pentagon[3] = find_intersection_point( [ [ [$star_3x, $star_3y], [$star_13x, $star_13y] ], [ [$star_17x, $star_17y], [$star_7x, $star_7y] ] ] ); $pentagon[4] = find_intersection_point( [ [ [$star_17x, $star_17y], [$star_7x, $star_7y] ], [ [$star_9x, $star_9y], [$star_3x, $star_3y] ] ] ); define_pieces( [ @pentagon ], "pentagon", "$pentagon_color" ); ($pentagon_0x, $pentagon_0y) = @{ $pentagon[0] }; ($pentagon_1x, $pentagon_1y) = @{ $pentagon[1] }; ($pentagon_2x, $pentagon_2y) = @{ $pentagon[2] }; ($pentagon_3x, $pentagon_3y) = @{ $pentagon[3] }; ($pentagon_4x, $pentagon_4y) = @{ $pentagon[4] }; @half_pentagon = (); ($star_0x, $star_0y) = @{ $star[0] }; ($star_10x, $star_10y) = @{ $star[10] }; $p1 = find_intersection_point( [ [ [$star_9x, $star_9y], [$star_11x, $star_11y] ], [ [$star_0x, $star_0y], [$star_10x, $star_10y] ] ] ); push @half_pentagon, $p1; push @half_pentagon, $pentagon[0]; push @half_pentagon, $pentagon[4]; push @half_pentagon, $pentagon[3]; ($half_pentagon_0x, $half_pentagon_0y) = @{ $half_pentagon[0] }; ($half_pentagon_1x, $half_pentagon_1y) = @{ $half_pentagon[1] }; ($half_pentagon_2x, $half_pentagon_2y) = @{ $half_pentagon[2] }; ($half_pentagon_3x, $half_pentagon_3y) = @{ $half_pentagon[3] }; $old_draw_border = $draw_border; $draw_border = 0; define_pieces( [ @half_pentagon ], "half_pentagon_core", "$pentagon_color" ); $draw_border = $old_draw_border; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; if($draw_border == 1) { $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; } $Elmer = $Elmer . '' . "\n\n"; @half_pentagon2 = (); push @half_pentagon2, $p1; push @half_pentagon2, $pentagon[1]; push @half_pentagon2, $pentagon[2]; push @half_pentagon2, $pentagon[3]; ($half_pentagon2_0x, $half_pentagon2_0y) = @{ $half_pentagon2[0] }; ($half_pentagon2_1x, $half_pentagon2_1y) = @{ $half_pentagon2[1] }; ($half_pentagon2_2x, $half_pentagon2_2y) = @{ $half_pentagon2[2] }; ($half_pentagon2_3x, $half_pentagon2_3y) = @{ $half_pentagon2[3] }; $old_draw_border = $draw_border; $draw_border = 0; define_pieces( [ @half_pentagon2 ], "half_pentagon2_core", "$pentagon_color" ); $draw_border = $old_draw_border; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; if($draw_border == 1) { $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; } $Elmer = $Elmer . '' . "\n\n"; # bottle $p1 = $star[9]; # point reference $p10 = $star[11]; # point reference $p6 = $star[19]; # point reference ($star_19x, $star_19y) = @{ $p6 }; $p5 = $star[1]; # point reference ($star_1x, $star_1y) = @{ $p5 }; $p3 = find_intersection_point( [ [ [$star_9x, $star_9y], [$star_3x, $star_3y] ], [ [$star_1x, $star_1y], [$star_7x, $star_7y] ] ] ); # 9 - 3 and 7 - 1 ($l5x1, $l5y1) = @{ $p3 }; ($star_12x, $star_12y) = @{ $star[12] }; $p8 = find_intersection_point( [ [ [$star_11x, $star_11y], [$star_17x, $star_17y] ], [ [$star_19x, $star_19y], [$star_13x, $star_13y] ] ] ); # 11 - 17 and 19 - 13 ($l6x1, $l6y1) = @{ $p8 }; ($star_8x, $star_8y) = @{ $star[8] }; ($l7x1, $l7y1) = @{ $p3 }; ($star_18x, $star_18y) = @{ $star[18] }; ($l8x1, $l8y1) = @{ $p8 }; ($star_2x, $star_2y) = @{ $star[2] }; ($star_9x, $star_9y) = @{ $star[9] }; ($star_19x, $l9y2) = @{ $star[19] }; $p2 = find_intersection_point( [ [ [$star_9x, $star_9y], [$star_19x, $star_19y] ], [ [$l5x1, $l5y1], [$star_12x, $star_12y] ] ] ); $p4 = find_intersection_point( [ [ [$l7x1, $l7y1], [$star_18x, $star_18y] ], [ [$star_11x, $star_11y], [$star_1x, $star_1y] ] ] ); $p7 = find_intersection_point( [ [ [$star_9x, $star_9y], [$star_19x, $star_19y] ], [ [$l8x1, $l8y1], [$star_2x, $star_2y] ] ] ); $p9 = find_intersection_point( [ [ [$l6x1, $l6y1], [$star_8x, $star_8y] ], [ [$star_11x, $star_11y], [$star_1x, $star_1y] ] ] ); @bottle = ($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, $p10); define_pieces( [ @bottle ], "bottle", "$bottle_color" ); ($bottle_0x, $bottle_0y) = @{ $p1 }; ($bottle_1x, $bottle_1y) = @{ $p2 }; ($bottle_2x, $bottle_2y) = @{ $p3 }; ($bottle_3x, $bottle_3y) = @{ $p4 }; ($bottle_4x, $bottle_4y) = @{ $p5 }; ($bottle_5x, $bottle_5y) = @{ $p6 }; ($bottle_6x, $bottle_6y) = @{ $p7 }; ($bottle_7x, $bottle_7y) = @{ $p8 }; ($bottle_8x, $bottle_8y) = @{ $p9 }; ($bottle_9x, $bottle_9y) = @{ $p10 }; @half_bottle = (); $p0 = find_intersection_point( [ [ [$star_0x, $star_0y], [$star_10x, $star_10y] ], [ [$star_9x, $star_9y], [$star_11x, $star_11y] ] ] ); push @half_bottle, $p0; push @half_bottle, $p1; push @half_bottle, $p2; push @half_bottle, $p3; push @half_bottle, $p4; push @half_bottle, $p5; $p11 = find_intersection_point( [ [ [$star_0x, $star_0y], [$star_10x, $star_10y] ], [ [$star_1x, $star_1y], [$star_19x, $star_19y] ] ] ); push @half_bottle, $p11; $old_draw_border = $draw_border; $draw_border = 0; define_pieces( [ @half_bottle ], "half_bottle_core", "$bottle_color" ); $draw_border = $old_draw_border; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; if($draw_border == 1) { ($half_bottle_0x, $half_bottle_0y) = @{ $p0 }; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($half_bottle_6x, $half_bottle_6y) = @{ $p11 }; $Elmer = $Elmer . '' . "\n"; } $Elmer = $Elmer . '' . "\n\n"; # doublepentagon ($l2x1, $l2y1) = @{ $star[15] }; ($l2x2, $l2y2) = @{ $star[1] }; ($l3x1, $l3y1) = @{ $star[15] }; ($l3x2, $l3y2) = @{ $star[9] }; ($l4x1, $l4y1) = @{ $star[11] }; ($l4x2, $l4y2) = @{ $star[5] }; ($l5x1, $l5y1) = @{ $star[9] }; ($l5x2, $l5y2) = @{ $star[19] }; ($l6x1, $l6y1) = @{ $star[7] }; ($l6x2, $l6y2) = @{ $star[1] }; $p1 = find_intersection_point( [ [ [$star_17x, $star_17y], [$star_11x, $star_11y] ], [ [$l2x1, $l2y1], [$l2x2, $l2y2] ] ] ); $p2 = find_intersection_point( [ [ [$l3x1, $l3y1], [$l3x2, $l3y2] ], [ [$star_17x, $star_17y], [$star_11x, $star_11y] ] ] ); ($l7x1, $l7y1) = @{ $p2 }; ($l7x2, $l7y2) = @{ $star[6] }; $p4 = find_intersection_point( [ [ [$l5x1, $l5y1], [$l5x2, $l5y2] ], [ [$l4x1, $l4y1], [$l4x2, $l4y2] ] ] ); ($l8x1, $l8y1) = @{ $star[16] }; ($l8x2, $l8y2) = @{ $p4 }; $p3 = find_intersection_point( [ [ [$l8x1, $l8y1], [$l8x2, $l8y2] ], [ [$l7x1, $l7y1], [$l7x2, $l7y2] ] ] ); $p5 = find_intersection_point( [ [ [$l6x1, $l6y1], [$l6x2, $l6y2] ], [ [$l4x1, $l4y1], [$l4x2, $l4y2] ] ] ); ($l9x1, $l9y1) = @{ $star[5] }; ($l9x2, $l9y2) = @{ $star[19] }; $p6 = find_intersection_point( [ [ [$l6x1, $l6y1], [$l6x2, $l6y2] ], [ [$l9x1, $l9y1], [$l9x2, $l9y2] ] ] ); $p8 = find_intersection_point( [ [ [$l5x1, $l5y1], [$l5x2, $l5y2] ], [ [$l2x1, $l2y1], [$l2x2, $l2y2] ] ] ); ($l10x1, $l10y1) = @{ $star[16] }; ($l10x2, $l10y2) = @{ $p6 }; ($l11x1, $l11y1) = @{ $star[6] }; ($l11x2, $l11y2) = @{ $p8 }; $p7 = find_intersection_point( [ [ [$l10x1, $l10y1], [$l10x2, $l10y2] ], [ [$l11x1, $l11y1], [$l11x2, $l11y2] ] ] ); @doublepentagon = ($p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8); define_pieces( [ @doublepentagon ], "doublepentagon", "$doublepentagon_color" ); #points ($l12x1, $l12y1) = @{ $doublepentagon[0] }; ($l12x2, $l12y2) = @{ $doublepentagon[1] }; ($l13x1, $l13y1) = @{ $doublepentagon[2] }; ($l13x2, $l13y2) = @{ $doublepentagon[3] }; $p9 = find_intersection_point( [ [ [$l12x1, $l12y1], [$l12x2, $l12y2] ], [ [$l13x1, $l13y1], [$l13x2, $l13y2] ] ] ); ($l14x1, $l14y1) = @{ $doublepentagon[4] }; ($l14x2, $l14y2) = @{ $doublepentagon[5] }; ($l15x1, $l15y1) = @{ $doublepentagon[7] }; ($l15x2, $l15y2) = @{ $doublepentagon[0] }; $p10 = find_intersection_point( [ [ [$l14x1, $l14y1], [$l14x2, $l14y2] ], [ [$l15x1, $l15y1], [$l15x2, $l15y2] ] ] ); @half_doublepentagon = (); push @half_doublepentagon, $p3; push @half_doublepentagon, $p2; push @half_doublepentagon, $p1; push @half_doublepentagon, $p8; push @half_doublepentagon, $p7; ($half_doublepentagon_0x, $half_doublepentagon_0y) = @{ $half_doublepentagon[0] }; ($half_doublepentagon_1x, $half_doublepentagon_1y) = @{ $half_doublepentagon[1] }; ($half_doublepentagon_2x, $half_doublepentagon_2y) = @{ $half_doublepentagon[2] }; ($half_doublepentagon_3x, $half_doublepentagon_3y) = @{ $half_doublepentagon[3] }; ($half_doublepentagon_4x, $half_doublepentagon_4y) = @{ $half_doublepentagon[4] }; $old_draw_border = $draw_border; $draw_border = 0; define_pieces( [ @half_doublepentagon ], "half_doublepentagon_core", "$doublepentagon_color" ); $draw_border = $old_draw_border; $Elmer = $Elmer . '' . "\n"; # draw needed lines $Elmer = $Elmer . '' . "\n"; if($draw_border == 1) { $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; } $Elmer = $Elmer . '' . "\n\n"; ##################### group definitions # b - bottle # s - star # k - kite # p - pentagon # d - doublepentagon #define group: kited_star $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: k_rising_star $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x2, $y2) = @{ $pentagon[3] }; $x_translation = $star_10x - $x2; $y_translation = $star_10y - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: k_half_star $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = $star_11x - $kite_2x; $y_translation = $star_11y - $kite_2y; $Elmer = $Elmer . '' . "\n"; $x_translation = $star_2x - $kite_2x; $y_translation = $star_2y - $kite_2y; $Elmer = $Elmer . '' . "\n"; ($star_2x, $star_2y) = @{ $star[2] }; ($x2, $y2) = @{ $pentagon[2] }; $x_translation = $star_2x - $x2; $y_translation = $star_2y - $y2; $Elmer = $Elmer . '' . "\n"; ($star_4x, $star_4y) = @{ $star[4] }; ($x2, $y2) = @{ $pentagon[3] }; $x_translation = $star_4x - $x2; $y_translation = $star_4y - $y2; $Elmer = $Elmer . '' . "\n"; ($star_6x, $star_6y) = @{ $star[6] }; ($x2, $y2) = @{ $pentagon[2] }; $x_translation = $star_6x - $x2; $y_translation = $star_6y - $y2; $Elmer = $Elmer . '' . "\n"; ($x2, $y2) = @{ $pentagon[2] }; $x_translation = $star_8x - $x2; $y_translation = $star_8y - $y2; $Elmer = $Elmer . '' . "\n"; ($x2, $y2) = @{ $pentagon[2] }; $x_translation = $star_10x - $x2; $y_translation = $star_10y - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: pentabottle $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[0] }; ($x2, $y2) = @{ $bottle[4] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: fivepentabottle $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = $bottle_9x - $bottle_4x; $y_translation = $bottle_9y - $bottle_4y; $Elmer = $Elmer . '' . "\n"; $x_translation = $bottle_0x - $bottle_5x; $y_translation = $bottle_0y - $bottle_5y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: capped_bottle $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[0] }; ($x2, $y2) = @{ $half_pentagon[1] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[1] }; ($x2, $y2) = @{ $pentagon[2] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[4] }; ($x2, $y2) = @{ $pentagon[0] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[6] }; ($x2, $y2) = @{ $pentagon[0] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: pentabottle2 $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $pentagon[0] }; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: pentangledbottle $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[4] }; ($x2, $y2) = @{ $pentagon[0] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[1] }; ($x2, $y2) = @{ $pentagon[2] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $bottle[8] }; ($x2, $y2) = @{ $pentagon[4] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: kdk $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $doublepentagon[2] }; $x_translation = $x1 - $kite_2x; $y_translation = $y1 - $kite_2y; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $doublepentagon[6] }; $x_translation = $x1 - $kite_2x; $y_translation = $y1 - $kite_2y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: kdk_up $Elmer = $Elmer . '' . "\n"; $x_translation = $kite_2x - $kite_0x; $y_translation = $kite_2y - $kite_0y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: kdk_down $Elmer = $Elmer . '' . "\n"; $x_translation = $kite_0x - $kite_2x; $y_translation = $kite_0y - $kite_2y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: diamond $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $doublepentagon[6] }; $x_translation = $x1 - $kite_2x; $y_translation = $y1 - $kite_2y; $Elmer = $Elmer . '' . "\n"; ($kite_1x, $kite_1y) = @{ $kite[1] }; ($x1, $y1) = @{ $doublepentagon[3] }; $x_translation = $x1 - $kite_1x; $y_translation = $y1 - $kite_1y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: half_diamond $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $half_doublepentagon[4] }; $x_translation = $x1 - $kite_2x; $y_translation = $y1 - $kite_2y; $Elmer = $Elmer . '' . "\n"; ($kite_1x, $kite_1y) = @{ $kite[1] }; ($x1, $y1) = @{ $half_doublepentagon[0] }; $x_translation = $x1 - $kite_1x; $y_translation = $y1 - $kite_1y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: half_diamond_plus $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $half_doublepentagon[1] }; ($x2, $y2) = @{ $bottle[0] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $half_doublepentagon[1] }; ($x2, $y2) = @{ $half_pentagon2[2] }; $x_translation = $x1 - $x2; $y_translation = $y1 - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: core_wheel $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x2, $y2) = @{ $pentagon[3] }; $x_translation = $star_10x - $x2; $y_translation = $star_10y - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: wheel $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x2, $y2) = @{ $pentagon[3] }; $x_translation = $star_10x - $x2; $y_translation = $star_10y - $y2; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = $topX - $star_1x; $y_translation = $topY - $star_1y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = ($long_star_6x - $pentagon_2x); $y_translation = ($long_star_6y - $pentagon_2y); $Elmer = $Elmer . '' . "\n"; $x_translation = ($long_star_7x - $pentagon_0x); $y_translation = ($long_star_7y - $pentagon_0y); $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: turned_wheel $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: turnedagain_wheel $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: upsidedown_half_star $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: half_stars_p $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $pentagon[1] }; $x_translation = $x1 - $star_2x; $y_translation = $y1 - $star_2y; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $pentagon[3] }; $x_translation = $x1 - $star_10x; $y_translation = $y1 - $star_10y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: bottle36 $Elmer = $Elmer . '' . "\n"; ($bottle_3x, $bottle_3y) = @{ $bottle[3] }; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; ######### two_andahalf_bottles $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($bottle_6x, $bottle_6y) = @{ $bottle[6] }; ($doublepentagon_4x, $doublepentagon_4y) = @{ $doublepentagon[4] }; $x_translation = $bottle_6x - $doublepentagon_4x; $y_translation = $bottle_6y - $doublepentagon_4y; $Elmer = $Elmer . '' . "\n"; ($doublepentagon_0x, $doublepentagon_0y) = @{ $doublepentagon[0] }; ($bottle_3x, $bottle_3y) = @{ $bottle[3] }; $x_translation = ($bottle_6x - $doublepentagon_4x) + ($doublepentagon_0x - $bottle_3x); $y_translation = ($bottle_6y - $doublepentagon_4y) + ($doublepentagon_0y - $bottle_3y); $Elmer = $Elmer . '' . "\n"; ($bottle_9x, $bottle_9y) = @{ $bottle[9] }; ($half_bottle_1x, $half_bottle_1y) = @{ $half_bottle[1] }; $x_translation = $bottle_9x - $half_bottle_1x; $y_translation = $bottle_9y - $half_bottle_1y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($bottle_0x, $bottle_0y) = @{ $bottle[0] }; ($half_pentagon2_2x, $half_pentagon2_2y) = @{ $half_pentagon2[2] }; $x_translation = $bottle_0x - $half_pentagon2_2x; $y_translation = $bottle_0y - $half_pentagon2_2y; $Elmer = $Elmer . '' . "\n"; $x_translation = $bottle_3x - $pentagon_2x; $y_translation = $bottle_3y - $pentagon_2y; $Elmer = $Elmer . '' . "\n"; $x_translation = $bottle_5x - $pentagon_1x; $y_translation = $bottle_5y - $pentagon_1y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; #define group: tile $Elmer = $Elmer . '' . "\n"; $updown = ($centerY - $star_11y); ($xk1, $yk1) = @{ $kite[2] }; ($xk2, $yk2) = @{ $kite[0] }; $corner1X = $centerX + ($long_star_1x - $long_star_6x) + ($kite_2x - $xk2); $corner1Y = $centerY + ($long_star_1y - $long_star_6y) + ($kite_2y - $yk2) - $updown; $x_translation = $corner1X - $xk2; $y_translation = $corner1Y - $yk2 - ($yk1 - $yk2) + $star_1y - $star_11y; $Elmer = $Elmer . '' . "\n"; $kstar_point = find_intersection_point( [ [ [$star_8x, $star_8y], [$star_7x, $star_7y] ], [ [$star_10x, $star_10y], [$star_11x, $star_11y] ] ] ); ($kstar_pointX, $kstar_pointY) = @{ $kstar_point }; $x_translation = $corner1X - $kstar_pointX; $y_translation = $corner1Y - $kstar_pointY; $Elmer = $Elmer . '' . "\n"; $y_translation = ($long_star_1y - $long_star_6y) + ($yk1 - $yk2) - $updown; $Elmer = $Elmer . '' . "\n"; $corner2X = $centerX + ($long_star_4x - $long_star_9x) + ($xk1 - $xk2); $corner2Y = $centerY + ($long_star_4y - $long_star_9y) + ($yk1 - $yk2) - $updown; $x_translation = $corner2X - $xk2; $y_translation = $corner2Y - $yk2 + ($yk2 - $yk1); $Elmer = $Elmer . '' . "\n"; $x_translation = ($long_star_3x - $star_4x) + ($star_19x - $star_0x); $y_translation = ($long_star_3y - $star_4y) + ($star_19y - $star_0y); $Elmer = $Elmer . '' . "\n"; $corner3X = $centerX + ($long_star_6x - $long_star_1x) + ($xk2 - $xk1); $corner3Y = $centerY + ($long_star_6y - $long_star_1y) + ($yk2 - $yk1) + $updown; $x_translation = ($long_star_6x - $long_star_1x); $y_translation = ($long_star_6y - $long_star_1y) + $star_1y - $star_11y + ($yk2 - $yk1); $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $kstar_point }; $x_translation = $corner3X - $x1; $y_translation = $corner3Y - $y1; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $long_star[9] }; ($x2, $y2) = @{ $long_star[4] }; $corner4X = $centerX + ($x1 - $x2) + ($xk2 - $xk1); $corner4Y = $centerY + ($y1 - $y2) + ($yk2 - $yk1) + $updown; $x_translation = $corner4X - $xk2; $y_translation = $corner4Y - $yk2 - ($yk1 - $yk2); $Elmer = $Elmer . '' . "\n"; $y_translation = ($y1 - $y2) + ($yk2 - $yk1) + $updown; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($pentagon_2x, $pentagon_2y) = @{ $pentagon[2] }; $x_translation = $corner2X - $centerX + ($centerX - $pentagon_2x); $y_translation = ($centerY - $pentagon_2y); $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; ($x1, $y1) = @{ $long_star[3] }; $x_translation = ($x1 - $star_4x) + ($star_19x - $star_0x); $y_translation = ($y1 - $star_4y) + ($star_19y - $star_0y); $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: bottled_wheel $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = $k_star_7x - $bottle_0x; $y_translation = $k_star_7y - $bottle_0y; $Elmer = $Elmer . '' . "\n"; $x_translation = $k_star_6x - $bottle_4x + ($pentagon_3x - $pentagon_4x); $y_translation = $k_star_6y - $bottle_4y + ($pentagon_3y - $pentagon_4y); $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: v_bridge $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = 0; $y_translation = $star_1y - $star_11y; $y_translation += 4 * ($kite_0y - $kite_2y); $y_translation += ($half_doublepentagon_4y - $half_doublepentagon_0y); $v_edge_centerY = $y_translation; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: v_edge $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group grand_tile $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = $long_star_4x; $x_translation *= 2; $h_edge_centerX = $x_translation; $y_translation = $bottomY; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: tipped_bottle $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; # define group: center $Elmer = $Elmer . '' . "\n"; $x_translation = $h_edge_centerX; $y_translation = $v_edge_centerY - $star_1y; $Elmer = $Elmer . '' . "\n"; $x_translation = $h_edge_centerX; $y_translation = $v_edge_centerY - $star_11y; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = $h_edge_centerX - $kstar_pointX; $y_translation = $v_edge_centerY - $kstar_pointY; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = $h_edge_centerX + $kstar_pointX + ($star_18x - $star_4x); $y_translation = $v_edge_centerY + $kstar_pointY; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = 0 - $long_star_0x; $y_translation = $v_edge_centerY + $topY; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $x_translation = 0 - $long_star_0x; $y_translation = $v_edge_centerY - $topY; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n"; $Elmer = $Elmer . '' . "\n\n"; $Elmer = $Elmer . '' . "\n\n"; ############ end defs ###### tile $Elmer = $Elmer . '' . "\n"; $dim = 2 * $h_edge_centerX; $vdim = 2 * $v_edge_centerY; $Elmer = $Elmer . '' . "\n"; ##### alternate tiling if(1 == 0) { $x_translation = (2 * $corner2X) - $corner1X - 1; $y_translation = 0; $Elmer = $Elmer . '' . "\n"; $x_translation = (4 * $corner2X) - $corner1X - 2; $y_translation = 0; $Elmer = $Elmer . '' . "\n"; $x_translation = 0 - $corner1X; $y_translation = $corner4Y - $corner1Y - 1; $Elmer = $Elmer . '' . "\n"; $x_translation = (2 * $corner2X) - $corner1X - 1; $y_translation = $corner4Y - $corner1Y - 1; $Elmer = $Elmer . '' . "\n"; $x_translation = (4 * $corner2X) - $corner1X - 2; $y_translation = $corner4Y - $corner1Y - 1; $Elmer = $Elmer . '' . "\n"; $x_translation = 0 - $corner1X; $y_translation = (2 * $corner4Y) - $corner1Y - 2; $Elmer = $Elmer . '' . "\n"; $x_translation = (2 * $corner2X) - $corner1X - 1; $y_translation = (2 * $corner4Y) - $corner1Y - 2; $Elmer = $Elmer . '' . "\n"; $x_translation = (4 * $corner2X) - $corner1X - 2; $y_translation = (2 * $corner4Y) - $corner1Y - 2; $Elmer = $Elmer . '' . "\n"; } $name = "infinitile.svg"; # Write SVG open(FUDD, "> $name"); print FUDD < ENDL print FUDD ' '."\n\n"; print FUDD "$Elmer \n"; print FUDD '' . "\n"; close FUDD; sub define_pieces { my $polypointref = shift; my $poly_id = shift; my $fill_color = shift; my @polypoints = @{ $polypointref }; my $pointref; my $x; my $y; my $polypointindex = 0; unless(defined($fill_color)) { $fill_color = "none"; } if($draw_border == 1) { $Elmer = $Elmer . ' ' . "\n\n"; } sub find_intersection_point { my $crossref = shift; # get data my ($line1ref, $line2ref) = @{$crossref}; # unravel my ($p1ref, $p2ref) = @{$line1ref}; my ($p3ref, $p4ref) = @{$line2ref}; my @p1 = @{$p1ref}; my @p2 = @{$p2ref}; my @p3 = @{$p3ref}; my @p4 = @{$p4ref}; my $xi; my $yi; my $slope1; my $slope2; unless(defined($p1[0]) && defined($p1[1]) && defined($p2[0]) && defined($p2[1]) && defined($p3[0]) && defined($p3[1]) && defined($p4[0]) && defined($p4[1])) { return 0; # no point } #$slope1 = ($p2[1] - $p1[1]) / ($p2[0] - $p1[0]); #$slope2 = ($p4[1] - $p3[1]) / ($p4[0] - $p3[0]); if( ( abs($p2[1] - $p1[1]) < 0.0000001) && (abs($p4[1] - $p3[1]) < 0.0000001) ) { return 0; # no point } # if x's or y's are equal then solve for second coordinate # x's equal if( abs($p1[0] - $p2[0]) < 0.0000001 ) { $xi = $p1[0]; $slope2 = ($p4[1] - $p3[1]) / ($p4[0] - $p3[0]); $yi = $p3[1] + ( $slope2 * ($xi - $p3[0]) ); return [$xi, $yi]; # return intersection point } elsif( abs($p3[0] - $p4[0]) < 0.0000001 ) { $xi = $p3[0]; $slope1 = ($p2[1] - $p1[1]) / ($p2[0] - $p1[0]); $yi = $p1[1] + ( $slope1 * ($xi - $p1[0]) ); return [$xi, $yi]; # return intersection point } $slope1 = ($p2[1] - $p1[1]) / ($p2[0] - $p1[0]); $slope2 = ($p4[1] - $p3[1]) / ($p4[0] - $p3[0]); # y's are equal if( abs($p2[1] - $p1[1]) < 0.0000001 ) { $yi = $p1[1]; $slope2 = ($p4[1] - $p3[1]) / ($p4[0] - $p3[0]); $xi = ( ( $yi - $p3[1] ) + ($slope2 * $p3[0]) ) / $slope2; return [$xi, $yi]; # return intersection point } elsif( abs($p4[1] - $p3[1]) < 0.0000001 ) { $yi = $p3[1]; $xi = ( ( $yi - $p1[1] ) + ($slope1 * $p1[0]) ) / $slope1; return [$xi, $yi]; # return intersection point } #if slopes are parallel, bailout if( abs($slope1 - $slope2) < 0.0000001 ) { return 0; # no point } $xi = ( ($slope1 * $p1[0]) - ($slope2 * $p3[0]) + $p3[1] - $p1[1] ) / ($slope1 - $slope2); $yi = $p1[1] + ($slope1 * ($xi - $p1[0])); return [$xi, $yi]; # return intersection point } print "\n\tThat's All, Folks!\n\n";