NAME

Math::PlanePath::MathImagePyramidReplicate -- replicating squares

SYNOPSIS

use Math::PlanePath::MathImagePyramidReplicate;
my $path = Math::PlanePath::MathImagePyramidReplicate->new;
my ($x, $y) = $path->n_to_xy (123);

DESCRIPTION

This is a self-similar replicating pyramid shape made from 4 points each,

                                           4

                                           3

                                           2

                                           1

                                       <- Y=0

                                          -1

                                          -2

                                          -3

                                          -4

                 ^
-4  -3  -2  -1  X=0  1   2   3   4

The base shape is the initial N=0 to N=8 section,

    +---+
    | 2 |
+---+---+---+
| 3 | 0 | 1 |
+---+---+---+

It then repeats inverted to make a similar shape but upside-down,

+---+---+---+---+---+---+---+
| 5   4   7 | 2 |13  12  15 |
+---+   +---+   +---+   +---+
    | 6 | 3   0   1 |14 |
    +---+---+---+---+---+
        | 9   8  11 |
        +---+   +---+
            |10 |
            +---+

Level Ranges

A given replication extends to ...

Nlevel = 4^level - 1
- ... <= X <= ...
- ... <= Y <= ...

Complex Base

This pattern corresponds to expressing a complex integer X+i*Y in base b=...

X+Yi = a[n]*b^n + ... + a[2]*b^2 + a[1]*b + a[0]

using complex digits a[i] encoded in N in integer base 4 ...

a[i] digit     N digit
----------     -------
     0            0
     1            1
     i            2
    -1            3

FUNCTIONS

See "FUNCTIONS" in Math::PlanePath for the behaviour common to all path classes.

$path = Math::PlanePath::MathImagePyramidReplicate->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::CornerReplicate, Math::PlanePath::SquareReplicate, Math::PlanePath::LTiling, Math::PlanePath::GosperReplicate, Math::PlanePath::QuintetReplicate