1Math::PlanePath::PyramiUdsSeprirCaoln(t3r)ibuted Perl DoMcautmhe:n:tPaltainoenPath::PyramidSpiral(3)
2
3
4

NAME

6       Math::PlanePath::PyramidSpiral -- integer points drawn around a pyramid
7

SYNOPSIS

9        use Math::PlanePath::PyramidSpiral;
10        my $path = Math::PlanePath::PyramidSpiral->new;
11        my ($x, $y) = $path->n_to_xy (123);
12

DESCRIPTION

14       This path makes a pyramid shaped spiral,
15
16                             31                          3
17                            /  \
18                          32 13 30                       2
19                         /  /  \  \
20                       33 14  3 12 29                    1
21                      /  /  /  \  \  \
22                    34 15  4  1--2 11 28 ...         <- Y=0
23                   /  /  /           \  \  \
24                 35 16  5--6--7--8--9-10 27 52          -1
25                /  /                       \  \
26              36 17-18-19-20-21-22-23-24-25-26 51       -2
27             /                                   \
28           37-38-39-40-41-42-43-44-45-46-47-48-49-50    -3
29
30                              ^
31           -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7
32
33       The perfect squares 1,4,9,16 fall one before the bottom left corner of
34       each loop, and the pronic numbers 2,6,12,20,30,etc are the vertical
35       upwards from X=1,Y=0.
36
37   Square Spiral
38       This spiral goes around at the same rate as the "SquareSpiral".  It's
39       as if two corners are cut off (like the "DiamondSpiral") and two others
40       extended (like the "OctagramSpiral").  The net effect is the same
41       looping rate but the points pushed around a bit.
42
43       Taking points up to a perfect square shows the similarity.  The two
44       triangular cut-off corners marked by "."s are matched by the two
45       triangular extensions.
46
47                   +--------------------+   7x7 square
48                   | .  .  . 31  .  .  .|
49                   | .  . 32 13 30  .  .|
50                   | . 33 14  3 12 29  .|
51                   |34 15  4  1  2 11 28|
52                 35|16  5  6  7  8  9 10|27
53              36 17|18 19 20 21 22 23 24|25 26
54           37 38 39|40 41 42 43 44 45 46|47 48 49
55                   +--------------------+
56
57   N Start
58       The default is to number points starting N=1 as shown above.  An
59       optional "n_start" can give a different start, with the same shape etc.
60       For example to start at 0,
61
62                       12         n_start => 0
63                      /  \
64                    13  2 11
65                   /  /  \  \
66                 14  3  0--1 10
67                /  /           \
68              15  4--5--6--7--8--9
69             /
70           16-17-18-19-20-21-22-...
71

FUNCTIONS

73       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
74       classes.
75
76       "$path = Math::PlanePath::PyramidSpiral->new ()"
77       "$path = Math::PlanePath::PyramidSpiral->new (n_start => $n)"
78           Create and return a new pyramid spiral object.
79
80       "$n = $path->xy_to_n ($x,$y)"
81           Return the point number for coordinates "$x,$y".  $x and $y are
82           each rounded to the nearest integer, which has the effect of
83           treating each N in the path as centred in a square of side 1, so
84           the entire plane is covered.
85

OEIS

87       This path is in Sloane's Online Encyclopedia of Integer Sequences as
88
89           <http://oeis.org/A053615> (etc)
90
91           n_start=1 (the default)
92             A053615    abs(X), distance to next pronic, but starts n=0
93             A054552    N on X axis, 4n^2 - 3n + 1
94             A033951    N on South-East diagonal, 4n^2 + 3n + 1
95
96             A214250    sum N of eight surrounding cells
97
98             A217013    permutation N of points in SquareSpiral order
99                          rotated +90 degrees
100             A217294    inverse
101
102       In the two permutations the pyramid spiral is conceived as starting to
103       the left and the square spiral starting upwards.  The paths here start
104       in the same direction (both to the right), hence rotate 90 to adjust
105       the orientation.
106
107           n_start=0
108             A001107    N on X axis, decagonal numbers
109             A002939    N on Y axis
110             A033991    N on X negative axis
111             A002943    N on Y negative axis
112             A007742    N on diagonal South-West
113             A033954    N on diagonal South-East, decagonal second kind
114
115           n_start=2
116             A185669    N on diagonal South-East
117

SEE ALSO

119       Math::PlanePath, Math::PlanePath::SquareSpiral,
120       Math::PlanePath::PyramidRows, Math::PlanePath::TriangleSpiral,
121       Math::PlanePath::TriangleSpiralSkewed
122

HOME PAGE

124       <http://user42.tuxfamily.org/math-planepath/index.html>
125

LICENSE

127       Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Kevin
128       Ryde
129
130       This file is part of Math-PlanePath.
131
132       Math-PlanePath is free software; you can redistribute it and/or modify
133       it under the terms of the GNU General Public License as published by
134       the Free Software Foundation; either version 3, or (at your option) any
135       later version.
136
137       Math-PlanePath is distributed in the hope that it will be useful, but
138       WITHOUT ANY WARRANTY; without even the implied warranty of
139       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
140       General Public License for more details.
141
142       You should have received a copy of the GNU General Public License along
143       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
144
145
146
147perl v5.30.1                      2020-01-30 Math::PlanePath::PyramidSpiral(3)
Impressum