1Math::PlanePath::OctagrUasmeSrpiCroanlt(r3i)buted Perl DMoactuhm:e:nPtlaatnieoPnath::OctagramSpiral(3)
2
3
4
6 Math::PlanePath::OctagramSpiral -- integer points drawn around an
7 octagram
8
10 use Math::PlanePath::OctagramSpiral;
11 my $path = Math::PlanePath::OctagramSpiral->new;
12 my ($x, $y) = $path->n_to_xy (123);
13
15 This path makes a spiral around an octagram (8-pointed star),
16
17 29 25 4
18 | \ / |
19 30 28 26 24 ...56-55 3
20 | \ / | /
21 33-32-31 7 27 5 23-22-21 54 2
22 \ |\ / | / /
23 34 9- 8 6 4- 3 20 53 1
24 \ \ / / /
25 35 10 1--2 19 52 <- Y=0
26 / / \ \
27 36 11-12 14 16-17-18 51 -1
28 / |/ \ | \
29 37-38-39 13 43 15 47-48-49-50 -2
30 | / \ |
31 40 42 44 46 -3
32 |/ \ |
33 41 45 -4
34
35 ^
36 -4 -3 -2 -1 X=0 1 2 3 4 5 ...
37
38 Each loop is 16 longer than the previous. The 18-gonal numbers
39 18,51,100,etc fall on the horizontal at Y=-1.
40
41 The inner corners like 23, 31, 39, 47 are similar to the "SquareSpiral"
42 path, but instead of going directly between them the octagram takes a
43 detour out to make the points of the star. Those excursions make each
44 loops 8 longer (1 per excursion), hence a step of 16 here as compared
45 to 8 for the "SquareSpiral".
46
47 N Start
48 The default is to number points starting N=1 as shown above. An
49 optional "n_start" can give a different start, in the same pattern.
50 For example to start at 0,
51
52 n_start => 0
53
54 28 24
55 29 27 25 23 ... 55 54
56 32 31 30 6 26 4 22 21 20 53
57 33 8 7 5 3 2 19 52
58 34 9 0 1 18 51
59 35 10 11 13 15 16 17 50
60 36 37 38 12 42 14 46 47 48 49
61 39 41 43 45
62 40 44
63
65 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
66 classes.
67
68 "$path = Math::PlanePath::OctagramSpiral->new ()"
69 Create and return a new octagram spiral object.
70
71 "($x,$y) = $path->n_to_xy ($n)"
72 Return the X,Y coordinates of point number $n on the path.
73
74 For "$n < 1" the return is an empty list, it being considered the
75 path starts at 1.
76
77 "$n = $path->xy_to_n ($x,$y)"
78 Return the point number for coordinates "$x,$y". $x and $y are
79 each rounded to the nearest integer, which has the effect of
80 treating each N in the path as centred in a square of side 1, so
81 the entire plane is covered.
82
84 X,Y to N
85 The symmetry of the octagram can be used by rotating a given X,Y back
86 to the first star excursion such as N=19 to N=23. If Y is negative
87 then rotate back by 180 degrees, then if X is negative rotate back by
88 90, and if Y>=X then by a further 45 degrees. Each such rotation, if
89 needed, is counted as a multiple of the side-length to be added to the
90 final N. For example at N=19 the side length is 2. Rotating by 180
91 degrees is 8 side lengths, by 90 degrees 4 sides, and by 45 degrees is
92 2 sides.
93
95 Entries in Sloane's Online Encyclopedia of Integer Sequences related to
96 this path include
97
98 <http://oeis.org/A125201> (etc)
99
100 n_start=1 (the default)
101 A125201 N on X axis, from X=1 onwards, 18-gonals + 1
102 A194268 N on diagonal South-East
103
104 n_start=0
105 A051870 N on X axis, 18-gonal numbers
106 A139273 N on Y axis
107 A139275 N on X negative axis
108 A139277 N on Y negative axis
109 A139272 N on diagonal X=Y
110 A139274 N on diagonal North-West
111 A139276 N on diagonal South-West
112 A139278 N on diagonal South-East, second 18-gonals
113
115 Math::PlanePath, Math::PlanePath::SquareSpiral,
116 Math::PlanePath::PyramidSpiral
117
119 <http://user42.tuxfamily.org/math-planepath/index.html>
120
122 Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019,
123 2020 Kevin Ryde
124
125 This file is part of Math-PlanePath.
126
127 Math-PlanePath is free software; you can redistribute it and/or modify
128 it under the terms of the GNU General Public License as published by
129 the Free Software Foundation; either version 3, or (at your option) any
130 later version.
131
132 Math-PlanePath is distributed in the hope that it will be useful, but
133 WITHOUT ANY WARRANTY; without even the implied warranty of
134 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
135 General Public License for more details.
136
137 You should have received a copy of the GNU General Public License along
138 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
139
140
141
142perl v5.32.1 2021-01-27Math::PlanePath::OctagramSpiral(3)