NAME

Math::PlanePath::PyramidReplicate -- replicating squares

SYNOPSIS

use Math::PlanePath::PyramidReplicate;
my $path = Math::PlanePath::PyramidReplicate->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::PyramidReplicate->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

HOME PAGE

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

LICENSE

Copyright 2011, 2012 Kevin Ryde

This file is part of Math-PlanePath.

Math-PlanePath 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-PlanePath 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-PlanePath. If not, see <http://www.gnu.org/licenses/>.