1Math::PlanePath::QuinteUtsCeerntCroenst(r3i)buted Perl DMoactuhm:e:nPtlaatnieoPnath::QuintetCentres(3)
2
3
4
6 Math::PlanePath::QuintetCentres -- self-similar "plus" shape centres
7
9 use Math::PlanePath::QuintetCentres;
10 my $path = Math::PlanePath::QuintetCentres->new;
11 my ($x, $y) = $path->n_to_xy (123);
12
14 This a self-similar curve tracing out a "+" shape like the
15 "QuintetCurve" but taking the centre of each square visited by that
16 curve.
17
18 92 12
19 / |
20 124-... 93 91--90 88 11
21 | \ \ / \
22 122-123 120 102 94 82 89 86--87 10
23 \ / | / | / / | |
24 121 119 103 101-100 95 81 83--84--85 9
25 \ \ \ \ \
26 114-115-116 118 104 32 99--98 96 80 78 8
27 | |/ / / | |/ |/ \
28 112-113 110 117 105 31 33--34 97 36 79 76--77 7
29 \ / \ \ \ \ / \ |
30 111 109-108 106 30 42 35 38--37 75 6
31 |/ / / | | /
32 107 29 43 41--40--39 74 5
33 \ \ |
34 24--25--26 28 44 46 72--73 70 68 4
35 | |/ |/ \ \ / \ / \
36 22--23 20 27 18 45 48--47 71 56 69 66--67 3
37 \ / \ / \ | / \ |
38 21 6 19 16--17 49 54--55 58--57 65 2
39 / \ | | \ | /
40 4-- 5 8-- 7 15 50--51 53 59 64 1
41 \ | / |/ | \
42 0-- 1 3 9 14 52 60--61 63 <- Y=0
43 |/ | \ |/
44 2 10--11 13 62 -1
45 |/
46 12 -2
47
48 ^
49 -1 X=0 1 2 3 4 5 6 7 8 9 10 11 12 13
50
51 The base figure is the initial the initial N=0 to N=4. It fills a "+"
52 shape as
53
54 .....
55 . .
56 . 4 .
57 . \.
58 ........\....
59 . . .\ .
60 . 0---1 . 3 .
61 . . | ./ .
62 ......|./....
63 . |/.
64 . 2 .
65 . .
66 .....
67
68 Arms
69 The optional "arms" parameter can give up to four copies of the curve,
70 each advancing successively. For example "arms=>4" is as follows.
71 Notice the N=4*k points are the plain curve, and N=4*k+1, N=4*k+2 and
72 N=4*k+3 are rotated copies of it.
73
74 69 ... 7
75 / | \
76 121 113 73 65--61 53 120 6
77 / \ / \ \ \ / \ /
78 ... 117 105-109 77 29 57 45--49 116 5
79 | / / | | \
80 101 81 25 33--37--41 96-100-104 112 4
81 | \ \ | |/
82 50 97--93 85 21 13 88--92 80 108 72 3
83 / | |/ |/ \ \ / \ / \
84 54 46--42 89 10 17 5-- 9 84 24 76 64--68 2
85 \ | / | | / \ |
86 58 38 14 6-- 2 1 16--20 32--28 60 1
87 / | \ \ | /
88 62 30--34 22--18 3 0-- 4 12 36 56 <- Y=0
89 | \ / | |/ | \
90 70--66 78 26 86 11-- 7 19 8 91 40--44 52 -1
91 \ / \ / \ \ / | / | |/
92 74 110 82 94--90 15 23 87 95--99 48 -2
93 / | | \ \ |
94 114 106-102--98 43--39--35 27 83 103 -3
95 \ | |/ / |
96 118 51--47 59 31 79 111-107 119 ... -4
97 / \ / \ \ \ / \ /
98 122 55 63--67 75 115 123 -5
99 \ |/
100 ... 71 -6
101
102 ^
103 -7 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6
104
105 The pattern an ever expanding "+" shape with first cell N=0 at the
106 origin. The further parts are effectively as follows,
107
108 +---+
109 | |
110 +---+--- +---+
111 | | |
112 +---+ +---+ +---+
113 | 2 | 1 | |
114 +---+ +---+---+ +---+
115 | | 3 | 0 |
116 +---+ +---+ +---+
117 | | |
118 +---+ +---+---+
119 | |
120 +---+
121
122 At higher replication levels the sides become wiggly and spiralling,
123 but they're symmetric and mesh to fill the plane.
124
126 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
127 classes.
128
129 "$path = Math::PlanePath::QuintetCentres->new ()"
130 "$path = Math::PlanePath::QuintetCentres->new (arms => $a)"
131 Create and return a new path object.
132
133 "($x,$y) = $path->n_to_xy ($n)"
134 Return the X,Y coordinates of point number $n on the path. Points
135 begin at 0 and if "$n < 0" then the return is an empty list.
136
137 Fractional positions give an X,Y position along a straight line
138 between the integer positions.
139
140 "$n = $path->n_start()"
141 Return 0, the first N in the path.
142
143 "($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)"
144 In the current code the returned range is exact, meaning $n_lo and
145 $n_hi are the smallest and biggest in the rectangle, but don't rely
146 on that yet since finding the exact range is a touch on the slow
147 side. (The advantage of which though is that it helps avoid very
148 big ranges from a simple over-estimate.)
149
150 Level Methods
151 "($n_lo, $n_hi) = $path->level_to_n_range($level)"
152 Return "(0, 5**$level - 1)", or for multiple arms return "(0, $arms
153 * 5**$level - 1)".
154
155 There are 5^level points in a level, or arms*5^level for multiple
156 arms, numbered starting from 0.
157
159 X,Y to N
160 The "xy_to_n()" calculation is similar to the "FlowsnakeCentres". For
161 a given X,Y a modulo 5 remainder is formed
162
163 m = (2*X + Y) mod 5
164
165 This distinguishes the five squares making up the base figure. For
166 example in the base N=0 to N=4 part the m values are
167
168 +-----+
169 | m=3 | 1
170 +-----+-----+-----+
171 | m=0 | m=2 | m=4 | <- Y=0
172 +-----+-----+-----+
173 | m=1 | -1
174 +-----+
175 X=0 1 2
176
177 From this remainder X,Y can be shifted down to the 0 position. That
178 position corresponds to a vector multiple of X=2,Y=1 and 90-degree
179 rotated forms of that vector. That vector can be divided out and X,Y
180 shrunk with
181
182 Xshrunk = (Y + 2*X) / 5
183 Yshrunk = (2*Y - X) / 5
184
185 If X,Y are considered a complex integer X+iY the effect is a remainder
186 modulo 2+i, subtract that to give a multiple of 2+i, then divide by
187 2+i. The vector X=2,Y=1 or 2+i is because that's the N=5 position
188 after the base shape.
189
190 The remainders can then be mapped to base 5 digits of N going from high
191 to low and making suitable rotations for the sub-part orientation of
192 the curve. The remainders alone give a traversal in the style of
193 "QuintetReplicate". Applying suitable rotations produces the connected
194 path of "QuintetCentres".
195
197 Entries in Sloane's Online Encyclopedia of Integer Sequences related to
198 this path include
199
200 <http://oeis.org/A106665> (etc)
201
202 A099456 level Y end, being Im((2+i)^k)
203
204 arms=2
205 A139011 level Y end, being Re((2+i)^k)
206
208 Math::PlanePath, Math::PlanePath::QuintetCurve,
209 Math::PlanePath::QuintetReplicate, Math::PlanePath::FlowsnakeCentres
210
212 <http://user42.tuxfamily.org/math-planepath/index.html>
213
215 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
216 Kevin Ryde
217
218 This file is part of Math-PlanePath.
219
220 Math-PlanePath is free software; you can redistribute it and/or modify
221 it under the terms of the GNU General Public License as published by
222 the Free Software Foundation; either version 3, or (at your option) any
223 later version.
224
225 Math-PlanePath is distributed in the hope that it will be useful, but
226 WITHOUT ANY WARRANTY; without even the implied warranty of
227 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
228 General Public License for more details.
229
230 You should have received a copy of the GNU General Public License along
231 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
232
233
234
235perl v5.36.0 2022-07-22Math::PlanePath::QuintetCentres(3)