and 1 contributors

# NAME

Math::PlanePath::GosperReplicate -- self-similar 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 self-similar hexagonal tiling of the plane. At each level the shape is the Gosper island.

``````                         17----16                     4
/        \
24----23    18    14----15                  3
/        \     \
25    21----22    19----20    10---- 9         2
\                          /        \
26----27     3---- 2    11     7---- 8      1
/        \     \
31----30     4     0---- 1    12----13     <- Y=0
/        \     \
32    28----29     5---- 6    45----44           -1
\                          /        \
33----34    38----37    46    42----43        -2
/        \     \
39    35----36    47----48           -3
\
40----41                          -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*b^2 + a*b + a``

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.

http://user42.tuxfamily.org/math-planepath/index.html