NAME
Math::PlanePath::GosperReplicate  selfsimilar hexagon replications
SYNOPSIS
use Math::PlanePath::GosperReplicate;
my $path = Math::PlanePath::GosperReplicate>new;
my ($x, $y) = $path>n_to_xy (123);
DESCRIPTION
This is a selfsimilar hexagonal tiling of the plane. At each level the shape is the Gosper island.
1716 4
/ \
2423 18 1415 3
/ \ \
25 2122 1920 10 9 2
\ / \
2627 3 2 11 7 8 1
/ \ \
3130 4 0 1 1213 < Y=0
/ \ \
32 2829 5 6 4544 1
\ / \
3334 3837 46 4243 2
/ \ \
39 3536 4748 3
\
4041 4
^
7 6 5 4 3 2 1 X=0 1 2 3 4 5 6 7
The points are spread out on every second X coordinate to make a a triangular lattice in integer coordinates (see "Triangular Lattice" in Math::PlanePath).
The basic pattern is the inner N=0 to N=6, then six copies of that shape are arranged around as the N=7,14,21,28,35,42 blocks. Then six copies of the N=0 to N=48 shape are replicated around, etc.
Each point represents a little hexagon, thus tiling the plane with hexagons. The innermost N=0 to N=6 are for instance,
* *
/ \ / \
/ \ / \
* * *
 3  2 
* * *
/ \ / \ / \
/ \ / \ / \
* * * *
 4  0  1 
* * * *
\ / \ / \ /
\ / \ / \ /
* * *
 5  6 
* * *
\ / \ /
\ / \ /
* *
The FlowsnakeCentres path is this same replicating shape, but starting from a side instead of the middle and with rotations and reflections to make points adjacent. The Flowsnake curve itself is this replication too, but following edges.
Complex Base
The path corresponds to expressing complex integers X+i*Y in a base b=5/2+i*sqrt(3)/2 with a bit of scaling to fit equilateral triangles to a square grid. So for integer X,Y both odd or both even,
X/2 + i*Y*sqrt(3)/2 = a[n]*b^n + ... + a[2]*b^2 + a[1]*b + a[0]
where each digit a[i] is either 0 or a sixth root of unity encoded into N as base 7 digits,
N digit a[i]
0 0
1 e^(0/3 * pi * i) = 1
2 e^(1/3 * pi * i) = 1/2 + i*sqrt(3)/2
3 e^(2/3 * pi * i) = 1/2 + i*sqrt(3)/2
4 e^(3/3 * pi * i) = 1
5 e^(4/3 * pi * i) = 1/2  i*sqrt(3)/2
6 e^(5/3 * pi * i) = 1/2  i*sqrt(3)/2
7 digits suffice because
norm(b) = (5/2)^2 + (sqrt(3)/2)^2 = 7
FUNCTIONS
See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.
$path = Math::PlanePath::GosperReplicate>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::GosperIslands, Math::PlanePath::QuintetReplicate, Math::PlanePath::Flowsnake, Math::PlanePath::FlowsnakeCentres
HOME PAGE
http://user42.tuxfamily.org/mathplanepath/index.html
LICENSE
Copyright 2011 Kevin Ryde
This file is part of MathPlanePath.
MathPlanePath 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.
MathPlanePath 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 MathPlanePath. If not, see <http://www.gnu.org/licenses/>.