NAME
Math::PlanePath::MathImageGosperIslands -- concentric Gosper islands
SYNOPSIS
use Math::PlanePath::MathImageGosperIslands;
my $path = Math::PlanePath::MathImageGosperIslands->new;
my ($x, $y) = $path->n_to_xy (123);
DESCRIPTION
In progress.
This path is integer versions of the Gosper island at successive levels arranged as concentric circles on a triangular lattice (see "Triangular Lattice" in Math::PlanePath). The Gosper island is the outline of a self-similar tiling of the plane by hexagons.
35----34
/ \
37----36 33----32 29----28
/ \ / \
38 31----30 27----26
\ \
39 25
/
--40 ...
11-----10 3
/ \
13----12 9---- 8 2
/ \
14 3---- 2 7 1
\ / \
15 4 0 1 24 <- Y=0
/ \ \
16 5----- 6 23 -1
\ /
17----18 21----22 -2
\ /
19----20 -3
-8 -7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6 7 8 9
The side N=1 to N=2 expands to the zig-zag N=7 to N=10, then each section of that expands similarly (and at those angles) to become N=25 to N=34, etc, becoming 3 times longer and wigglier at each level. The N=25 ring shown in part above is as follows.
* *
* * * * * *
* * * * *
* *
* * *
* * *
* *
* * *
* *
* * *
* *
* * *
* * *
* *
* * * * *
* * * * * *
* *
Each ring is the outline of seven copies of the previous level's shape arranged one in the centre and six around. So this N=25 shape is seven of the N=7 to N=24 shapes. The sides become successively bumpier at each level but they fit together exactly because the six sides are symmetric.
Level Ranges
Counting the inner hexagon as level=1, the ring for each level begins at
Nstart = 3^level - 2
length = 2*3^level
For example level=3 is at Nstart=3^3-2=25.
The packing of six copies of one island to make the next level happens at successively rotated positions, so the Nstart position is not on the X axis. Effectively a radial spoke N=0 to N=1 expands by the same zigzag as the side,
*---*
/
*---* becomes *---*
And replicating in this self-similar at each level, the same as the sides. Spokes like this at each level are the corners where the six copied islands are positioned. In any case the across, up, across pattern means each Nstart is at a successively rotated position. N=7 start at X=5,Y=1 is
angle = atan(1*sqrt(3) / 5) = 19.106.. degrees
The subsequent starts are multiples of this angle, for example N=25 at 2*angle, then N=79 at 3*angle, etc. The sqrt(3) factor as usual turns the flattened triangular grid into proper equilateral triangles.
Fractal Island
The Gosper island is usually conceived as a fractal with the initial hexagon in a fixed position and ever finer level of wiggliness. The code here can be used for that by rotating the Nstart position back to the X axis and scaling it down to a whatever desired unit radius.
scale factor = 1 / hypot(Y*sqrt(3), X)
rotate angle = - atan2 (Y*sqrt(3), X)
This puts the Nstart at X=1,Y=0, and further points at the ring around from that. Use Y*sqrt(3) on all points to turn the integer coordinates into proper equilateral triangles.
FUNCTIONS
$path = Math::PlanePath::MathImageGosperIslands->new ()
-
Create and return a new path object.
($x,$y) = $path->n_to_xy ($n)
-
Return the X,Y coordinates of point number
$n
on the path. Points begin at 0 and if$n < 0
then the return is an empty list.
SEE ALSO
Math::PlanePath, Math::PlanePath::KochCurve
HOME PAGE
http://user42.tuxfamily.org/math-image/index.html
LICENSE
Copyright 2011 Kevin Ryde
Math-Image 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, or (at your option) any later version.
Math-Image 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 Math-Image. If not, see <http://www.gnu.org/licenses/>.