1Math::PlanePath::AnvilSUpsierralC(o3n)tributed Perl DocuMmaetnht:a:tPiloannePath::AnvilSpiral(3)
2
3
4

NAME

6       Math::PlanePath::AnvilSpiral -- integer points around an "anvil" shape
7

SYNOPSIS

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

DESCRIPTION

14       This path makes a spiral around an anvil style shape,
15
16                                  ...-78-77-76-75-74       4
17                                                 /
18           49-48-47-46-45-44-43-42-41-40-39-38 73          3
19             \                             /  /
20              50 21-20-19-18-17-16-15-14 37 72             2
21                \  \                 /  /  /
22                 51 22  5--4--3--2 13 36 71                1
23                   \  \  \     /  /  /  /
24                    52 23  6  1 12 35 70              <- Y=0
25                   /  /  /        \  \  \
26                 53 24  7--8--9-10-11 34 69               -1
27                /  /                    \  \
28              54 25-26-27-28-29-30-31-32-33 68            -2
29             /                                \
30           55-56-57-58-59-60-61-62-63-64-65-66-67         -3
31
32                              ^
33           -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5  6  7
34
35       The pentagonal numbers 1,5,12,22,etc, P(k) = (3k-1)*k/2 fall
36       alternately on the X axis X>0, and on the Y=1 horizontal X<0.
37
38       Those pentagonals are always composites, from the factorization shown,
39       and as noted in "Step 3 Pentagonals" in Math::PlanePath::PyramidRows,
40       the immediately preceding P(k)-1 and P(k)-2 are also composites.  So
41       plotting the primes on the spiral has a 3-high horizontal blank line at
42       Y=0,-1,-2 for positive X, and Y=1,2,3 for negative X (after the first
43       few values).
44
45       Each loop around the spiral is 12 longer than the preceding.  This is
46       4* more than the step=3 "PyramidRows" so straight lines on a
47       "PyramidRows" like these pentagonals are also straight lines here, but
48       split into two parts.
49
50       The outward diagonal excursions are similar to the "OctagramSpiral",
51       but there's just 4 of them here where the "OctagramSpiral" has 8.  This
52       is reflected in the loop step.  The basic "SquareSpiral" is step 8, but
53       by taking 4 excursions here increases that to 12, and in the
54       "OctagramSpiral" 8 excursions adds 8 to make step 16.
55
56   Wider
57       An optional "wider" parameter makes the path wider by starting with a
58       horizontal section of given width.  For example
59
60           $path = Math::PlanePath::SquareSpiral->new (wider => 3);
61
62       gives
63
64           33-32-31-30-29-28-27-26-25-24-23 ...            2
65             \                          /  /
66              34 11-10--9--8--7--6--5 22 51                1
67                \  \              /  /  /
68                 35 12  1--2--3--4 21 50              <- Y=0
69                /  /                 \  \
70              36 13-14-15-16-17-18-19-20 49               -1
71             /                             \
72           37-38-39-40-41-42-43-44-45-46-47-48            -2
73
74                              ^
75           -6 -5 -4 -3 -2 -1 X=0 1  2  3  4  5
76
77       The starting point 1 is shifted to the left by ceil(wider/2) places to
78       keep the spiral centred on the origin X=0,Y=0.  This is the same
79       starting offset as the "SquareSpiral" "wider".
80
81       Widening doesn't change the nature of the straight lines which arise,
82       it just rotates them around.  Each loop is still 12 longer than the
83       previous, since the widening is essentially a constant amount in each
84       loop.
85
86   N Start
87       The default is to number points starting N=1 as shown above.  An
88       optional "n_start" can give a different start with the same shape.  For
89       example to start at 0,
90
91           n_start => 0
92
93           20-19-18-17-16-15-14-13 ...
94             \                 /  /
95              21  4--3--2--1 12 35
96                \  \     /  /  /
97                 22  5  0 11 34
98                /  /        \  \
99              23  6--7--8--9-10 33
100             /                    \
101           24-25-26-27-28-29-30-31-32
102
103       The only effect is to push the N values around by a constant amount.
104       It might help match coordinates with something else zero-based.
105

FUNCTIONS

107       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
108       classes.
109
110       "$path = Math::PlanePath::AnvilSpiral->new ()"
111       "$path = Math::PlanePath::AnvilSpiral->new (wider => $integer, n_start
112       => $n)"
113           Create and return a new anvil spiral object.  An optional "wider"
114           parameter widens the spiral path, it defaults to 0 which is no
115           widening.
116

OEIS

118       Entries in Sloane's Online Encyclopedia of Integer Sequences related to
119       this path include
120
121           <http://oeis.org/A033581> (etc)
122
123           default wider=0, n_start=1
124             A033570    N on X axis, alternate pentagonals (2n+1)*(3n+1)
125             A126587    N on Y axis
126             A136392    N on Y negative (n=-Y+1)
127             A033568    N on X=Y diagonal, alternate second pents (2*n-1)*(3*n-1)
128             A085473    N on south-east diagonal
129
130           wider=0, n_start=0
131             A211014    N on X axis, 14-gonal numbers of the second kind
132             A139267    N on Y axis, 2*octagonal
133             A049452    N on X negative, alternate pentagonals
134             A033580    N on Y negative, 4*pentagonals
135             A051866    N on X=Y diagonal, 14-gonal numbers
136             A094159    N on north-west diagonal, 3*hexagonals
137             A049453    N on south-west diagonal, alternate second pentagonal
138             A195319    N on south-east diagonal, 3*second hexagonals
139
140           wider=1, n_start=0
141             A051866    N on X axis, 14-gonal numbers
142             A049453    N on Y negative, alternate second pentagonal
143             A033569    N on north-west diagonal
144             A085473    N on south-west diagonal
145             A080859    N on Y negative
146             A033570    N on south-east diagonal
147                          alternate pentagonals (2n+1)*(3n+1)
148
149           wider=2, n_start=1
150             A033581    N on Y axis (6*n^2) except for initial N=2
151

SEE ALSO

153       Math::PlanePath, Math::PlanePath::SquareSpiral,
154       Math::PlanePath::OctagramSpiral, Math::PlanePath::HexSpiral
155

HOME PAGE

157       <http://user42.tuxfamily.org/math-planepath/index.html>
158

LICENSE

160       Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Kevin Ryde
161
162       This file is part of Math-PlanePath.
163
164       Math-PlanePath is free software; you can redistribute it and/or modify
165       it under the terms of the GNU General Public License as published by
166       the Free Software Foundation; either version 3, or (at your option) any
167       later version.
168
169       Math-PlanePath is distributed in the hope that it will be useful, but
170       WITHOUT ANY WARRANTY; without even the implied warranty of
171       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
172       General Public License for more details.
173
174       You should have received a copy of the GNU General Public License along
175       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
176
177
178
179perl v5.32.0                      2020-07-28   Math::PlanePath::AnvilSpiral(3)
Impressum