.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Math::PlanePath::GosperIslands 3pm" .TH Math::PlanePath::GosperIslands 3pm "2014-06-14" "perl v5.20.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Math::PlanePath::GosperIslands \-\- concentric Gosper islands .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Math::PlanePath::GosperIslands; \& my $path = Math::PlanePath::GosperIslands\->new; \& my ($x, $y) = $path\->n_to_xy (123); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This path is integer versions of the Gosper island at successive levels, arranged as concentric rings on a triangular lattice (see \&\*(L"Triangular Lattice\*(R" in Math::PlanePath). Each island is the outline of a self-similar tiling of the plane by hexagons, and the sides are self-similar expansions of line segments .IX Xref "Gosper, William" .PP .Vb 7 \& 35\-\-\-\-34 8 \& / \e \& ..\-36 33\-\-\-\-32 29\-\-\-\-28 7 \& \e / \e \& 31\-\-\-\-30 27\-\-\-\-26 6 \& \e \& 25 5 \& \& 78 4 \& \e \& 11\-\-\-\-\-10 77 3 \& / \e / \& 13\-\-\-\-12 9\-\-\-\- 8 76 2 \& / \e \e \& 14 3\-\-\-\- 2 7 ... 1 \& \e / \e \& 15 4 1 24 <\- Y=0 \& / \e \e \& 16 5\-\-\-\-\- 6 23 \-1 \& \e / \& 17\-\-\-\-18 21\-\-\-\-22 \-2 \& \e / \& 19\-\-\-\-20 \-3 \& \& \& \& \& \-5 \-4 \-3 \-2 \-1 X=0 1 2 3 4 5 6 7 8 9 10 11 .Ve .SS "Hexagon Replications" .IX Subsection "Hexagon Replications" The islands can be thought of as a self-similar tiling of the plane by hexagonal shapes. The innermost hexagon N=1 to N=6 is replicated six times to make the next outline N=7 to N=24. .PP .Vb 10 \& *\-\-\-* \& / \e \& *\-\-\-* *\-\-\-* \& / \e / \e \& * *\-\-\-* * \& \e / \e / \& *\-\-\-* *\-\-\-* \& / \e / \e \& * *\-\-\-* * \& \e / \e / \& *\-\-\-* *\-\-\-* \& \e / \& *\-\-\-* .Ve .PP Then that shape is in turn replicated six times around itself to make the next level. .PP .Vb 10 \& *\-\-\-E \& / \e \& *\-\-\-* *\-\-\-* *\-\-\-* \& / \e / \e \& * *\-\-\-* *\-\-\-* \& \e / \e \& * * D \& / \e / \& *\-\-\-* * * \& / \e / \e \& *\-\-\-* *\-\-\-* *\-\-\-* * \& / \e / \e / \& * *\-\-\-* *\-\-\-* *\-\-\-* \& \e / \e / \e \& * * C\-\-\-* *\-\-\-* \& / \e / \e \& * * O * * \& \e / \e / \& *\-\-\-* *\-\-\-* * * \& \e / \e / \e \& *\-\-\-* *\-\-\-* *\-\-\-* * \& / \e / \e / \& * *\-\-\-* *\-\-\-* *\-\-\-* \& \e / \e / \& * * *\-\-\-* \& / \e / \& * * * \& \e / \e \& *\-\-\-* *\-\-\-* * \& \e / \e / \& *\-\-\-* *\-\-\-* *\-\-\-* \& \e / \& *\-\-\-* .Ve .PP The shapes here and at higher level are like hexagons with wiggly sides. The sides are symmetric, so they mate on opposite sides but the join \&\*(L"corner\*(R" is not on the X axis (after the first level). For example the point marked \*(L"C\*(R" (N=7) is above the axis at X=5,Y=1. The next replication joins at point \*(L"D\*(R" (N=25) at X=11,Y=5. .SS "Side and Radial Lines" .IX Subsection "Side and Radial Lines" The sides at each level is a self-similar line segment expansion, .PP .Vb 3 \& *\-\-\-* \& *\-\-\-* becomes / \& *\-\-\-* .Ve .PP This expanding side shape is also the radial line or spoke from the origin out to \*(L"corner\*(R" join points. At level 0 they're straight lines, .PP .Vb 8 \& ...\-\-\-\-* \& / \e \& / \e side \& / \e \& / \e \& O\-\-\-\-\-\-\-\-\-* \& / \& / .Ve .PP Then at higher levels they're wiggly, such as level 1, .PP .Vb 7 \& ...\-\-* \& / \e \& * *\-\-\-* \& \e \e \& * *\-\-\-C \& / / / \& O\-\-\-* ... .Ve .PP Or level 2, .PP .Vb 10 \& *\-\-\-E \& ... / \e \& * *\-\-\-* *\-\-\-* \& \e \e / \e \& * *\-\-\-* *\-\-\-* \& / \e \& * *\-\-\-D \& \e / / \& *\-\-\-* *\-\-\-* ... \& \e / \& * * \& / \e \& * * \& \e / \& * *\-\-\-C \& / / \& O\-\-\-* .Ve .PP The lines become ever wigglier at higher levels, and in fact become \*(L"S\*(R" shapes with the ends spiralling around and in (and in fact middle sections likewise S and spiralling, to a lesser extent). .PP The spiralling means that the X axis is crossed multiple times at higher levels. For example in level 11 X>0,Y=0 occurs 22 times between N=965221 and N=982146. Likewise on diagonal lines X=Y and X=\-Y which are \*(L"sixths\*(R" of the initial hexagon. .PP The self-similar spiralling means the Y axis too is crossed multiple times at higher levels. In level 11 again X=0,Y>0 is crossed 7 times between N=1233212 and N=1236579. (Those N's are bigger than the X axis crossing, because the Nstart position at level 11 has rotated around some 210 degrees to just under the negative X axis.) .PP In general any radial straight line is crossed many times way eventually. .SS "Level Ranges" .IX Subsection "Level Ranges" Counting the inner hexagon as level=0, the side length and whole ring is .PP .Vb 2 \& sidelen = 3^level \& ringlen = 6 * 3^level .Ve .PP The starting N for each level is the total points preceding it, so .PP .Vb 2 \& Nstart = 1 + ringlen(0) + ... + ringlen(level\-1) \& = 3^(level+1) \- 2 .Ve .PP For example level=2 starts at Nstart=3^3\-2=25. .PP The way the side/radial lines expand as described above makes the Nstart position rotate around at each level. N=7 is at X=5,Y=1 which is angle .PP .Vb 2 \& angle = arctan(1*sqrt(3) / 5) \& = 19.106.. degrees .Ve .PP The \fIsqrt\fR\|(3) factor as usual turns the flattened integer X,Y coordinates into proper equilateral triangles. The further levels are then multiples of that angle. For example N=25 at X=11,Y=5 is 2*angle, or N=79 at X=20,Y=18 at 3*angle. .PP The N=7 which is the first radial replication at X=5,Y=1, scaled to unit sided equilateral triangles, has distance from the origin .PP .Vb 2 \& d1 = hypot(5, 1*sqrt(3)) / 2 \& = sqrt(7) .Ve .PP The subsequent levels are powers of that \fIsqrt\fR\|(7), .PP .Vb 1 \& Xstart,Ystart of the Nstart(level) position \& \& d = hypot(Xstart,Ystart*sqrt(3))/2 \& = sqrt(7) ^ level .Ve .PP This multiple of the angle and powering of the radius means the Nstart points are on a logarithmic spiral. .SS "Fractal Island" .IX Subsection "Fractal Island" The Gosper island is usually conceived as a fractal, with the initial hexagon in a fixed position and the sides having the line segment substitution described above, for ever finer levels of \*(L"S\*(R" spiralling wiggliness. The code here can be used for that by rotating the Nstart position back to the X axis and scaling down to a desired unit radius. .PP .Vb 1 \& Xstart,Ystart of the Nstart(level) position \& \& scale factor = 0.5 / hypot(Ystart*sqrt(3), Xstart) \& rotate angle = \- atan2 (Ystart*sqrt(3), Xstart) .Ve .PP This scale and rotate puts the Nstart point at X=1,Y=0 and further points of the ring around from that. Remember the \fIsqrt\fR\|(3) factor on Y for all points to turn the integer coordinates into proper equilateral triangles. .PP Notice the line segment substitution doesn't change the area of the initial hexagon. Effectively (and not to scale), .PP .Vb 5 \& * \& / \e \& *\-\-\-\-\-\-\-* becomes * / * \& \e / \& * .Ve .PP So the area lost below is gained above (or vice versa). The result is a line of ever greater length enclosing an unchanging area. .SH "FUNCTIONS" .IX Header "FUNCTIONS" See \*(L"\s-1FUNCTIONS\*(R"\s0 in Math::PlanePath for behaviour common to all path classes. .ie n .IP """$path = Math::PlanePath::GosperIslands\->new ()""" 4 .el .IP "\f(CW$path = Math::PlanePath::GosperIslands\->new ()\fR" 4 .IX Item "$path = Math::PlanePath::GosperIslands->new ()" Create and return a new path object. .ie n .IP """($x,$y) = $path\->n_to_xy ($n)""" 4 .el .IP "\f(CW($x,$y) = $path\->n_to_xy ($n)\fR" 4 .IX Item "($x,$y) = $path->n_to_xy ($n)" Return the X,Y coordinates of point number \f(CW$n\fR on the path. Points begin at 1 and if \f(CW\*(C`$n < 0\*(C'\fR then the return is an empty list. .SH "SEE ALSO" .IX Header "SEE ALSO" Math::PlanePath, Math::PlanePath::KochSnowflakes, Math::PlanePath::GosperSide .SH "HOME PAGE" .IX Header "HOME PAGE" .SH "LICENSE" .IX Header "LICENSE" Copyright 2011, 2012, 2013, 2014 Kevin Ryde .PP Math-PlanePath is free software; you can redistribute it and/or modify it under the terms of the \s-1GNU\s0 General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. .PP Math-PlanePath is distributed in the hope that it will be useful, but \&\s-1WITHOUT ANY WARRANTY\s0; without even the implied warranty of \s-1MERCHANTABILITY\s0 or \s-1FITNESS FOR A PARTICULAR PURPOSE. \s0 See the \s-1GNU\s0 General Public License for more details. .PP You should have received a copy of the \s-1GNU\s0 General Public License along with Math-PlanePath. If not, see .