1Math::PlanePath::QuinteUtsCeurrvCeo(n3t)ributed Perl DocMuamtehn:t:aPtliaonnePath::QuintetCurve(3)
2
3
4

NAME

6       Math::PlanePath::QuintetCurve -- self-similar "plus" shaped curve
7

SYNOPSIS

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

DESCRIPTION

14       This path is Mandelbrot's "quartet" trace of spiralling self-similar
15       "+" shape.
16
17           Benoit B. Mandelbrot, "The Fractal Geometry of Nature", W. H.
18           Freeman and Co., 1983, ISBN 0-7167-1186-9, section 7, "Harnessing
19           the Peano Monster Curves", pages 72-73.
20
21                   125--...                 93--92                      11
22                     |                       |   |
23               123-124                      94  91--90--89--88          10
24                 |                           |               |
25               122-121-120 103-102          95  82--83  86--87           9
26                         |   |   |           |   |   |   |
27               115-116 119 104 101-100--99  96  81  84--85               8
28                 |   |   |   |           |   |   |
29           113-114 117-118 105  32--33  98--97  80--79--78               7
30             |               |   |   |                   |
31           112-111-110-109 106  31  34--35--36--37  76--77               6
32                         |   |   |               |   |
33                       108-107  30  43--42  39--38  75                   5
34                                 |   |   |   |       |
35                        25--26  29  44  41--40  73--74                   4
36                         |   |   |   |           |
37                    23--24  27--28  45--46--47  72--71--70--69--68       3
38                     |                       |                   |
39                    22--21--20--19--18  49--48  55--56--57  66--67       2
40                                     |   |       |       |   |
41                     5---6---7  16--17  50--51  54  59--58  65           1
42                     |       |   |           |   |   |       |
43             0---1   4   9---8  15          52--53  60--61  64       <- Y=0
44                 |   |   |       |                       |   |
45                 2---3  10--11  14                      62--63          -1
46                             |   |
47                            12--13                                      -2
48
49             ^
50            X=0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 ...
51
52       Mandelbrot calls this a "quartet", taken as 4 parts around a further
53       middle part (like 4 players around a table).  The module name "quintet"
54       here is a mistake, though it does suggest the base-5 nature of the
55       curve.
56
57       The base figure is the initial N=0 to N=5.
58
59                     5
60                     |
61                     |
62             0---1   4      base figure
63                 |   |
64                 |   |
65                 2---3
66
67       It corresponds to a traversal of the following "+" shape,
68
69                .... 5
70                .    ^
71                .   <|
72                     |
73           0--->1 .. 4 ....
74             v  ^    |    .
75           .    |>   |>   .
76           .    |    v    .
77           .... 2--->3 ....
78                . v  .
79                .    .
80                .    .
81                . .. .
82
83       The "v" and ">" notches are the side the figure is directed at the
84       higher replications.  The 0, 2 and 3 sub-curves are the right hand side
85       of the line and are a plain repetition of the base figure.  The 1 and 4
86       parts are to the left and are a reversal (rotate the base figure 180
87       degrees).  The first such reversal is seen in the sample above as N=5
88       to N=10.
89
90               .....
91               .   .
92
93           5---6---7 ...
94           .   .   |   .
95           .       |   .   reversed figure
96           ... 9---8 ...
97               |   .
98               |   .
99              10 ...
100
101       Mandelbrot gives the expansion without designating start and end.  The
102       start is chosen here so the expansion has sub-curve 0 forward (not
103       reverse).  This ensures the next expansion has the curve the same up to
104       the preceding level, and extending from there.
105
106       In the base figure it can be seen the N=5 endpoint is rotated up around
107       from the N=0 to N=1 direction.  This makes successive higher levels
108       slowly spiral around.
109
110           base b = 2 + i
111           N = 5^level
112           angle = level * arg(b) = level*atan(1/2)
113                 = level * 26.56 degrees
114
115       In the sample shown above N=125 is level=3 and has spiralled around to
116       angle 3*26.56=79.7 degrees.  The next level goes to X negative in the
117       second quadrant.  A full circle around the plane is approximately level
118       14.
119
120   Arms
121       The optional "arms => $a" parameter can give 1 to 4 copies of the
122       curve, each advancing successively.  For example "arms=>4" is as
123       follows.  N=4*k points are the plain curve, and N=4*k+1, N=4*k+2 and
124       N=4*k+3 are rotated copies of it.
125
126                           69--65                      ...
127                            |   |                       |
128           ..-117-113-109  73  61--57--53--49         120
129                        |   |               |           |
130                  101-105  77  25--29  41--45 100-104 116
131                    |       |   |   |   |       |   |   |
132                   97--93  81  21  33--37  92--96 108-112
133                        |   |   |           |
134               50--46  89--85  17--13-- 9  88--84--80--76--72
135                |   |                   |                   |
136               54  42--38  10-- 6   1-- 5  20--24--28  64--68
137                |       |   |   |           |       |   |
138               58  30--34  14   2   0-- 4  16  36--32  60
139                |   |       |           |   |   |       |
140           66--62  26--22--18   7-- 3   8--12  40--44  56
141            |                   |                   |   |
142           70--74--78--82--86  11--15--19  87--91  48--52
143                            |           |   |   |
144              110-106  94--90  39--35  23  83  95--99
145                |   |   |       |   |   |   |       |
146              114 102--98  47--43  31--27  79 107-103
147                |           |               |   |
148              118          51--55--59--63  75 111-115-119-..
149                |                       |   |
150               ...                     67--71
151
152       The curve is essentially an ever expanding "+" shape with one corner at
153       the origin.  Four such shapes pack as follows.  O is the origin and
154       each * is the end of the part on its right.
155
156                       +---+
157                       |   |
158               +---*---    +---+
159               |   |     B     |
160           +---+   +---+   +---*
161           |     C     |   |   |
162           +---+   +---O---+   +---+
163               |   |   |     A     |
164               *---+   +---+   +---+
165               |     D     |   |
166               +---+   +---*---+
167                   |   |
168                   +---+
169
170       At higher replication levels the sides are wiggly and spiralling and
171       the centres of each rotate around, but their sides are symmetric and
172       mesh together perfectly to fill the plane.
173

FUNCTIONS

175       See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
176       classes.
177
178       "$path = Math::PlanePath::QuintetCurve->new ()"
179       "$path = Math::PlanePath::QuintetCurve->new (arms => $a)"
180           Create and return a new path object.
181
182       "($x,$y) = $path->n_to_xy ($n)"
183           Return the X,Y coordinates of point number $n on the path.  Points
184           begin at 0 and if "$n < 0" then the return is an empty list.
185
186           Fractional positions give an X,Y position along a straight line
187           between the integer positions.
188
189       "$n = $path->n_start()"
190           Return 0, the first N in the path.
191
192       "($n_lo, $n_hi) = $path->rect_to_n_range ($x1,$y1, $x2,$y2)"
193           In the current code the returned range is exact, meaning $n_lo and
194           $n_hi are the smallest and biggest in the rectangle, but don't rely
195           on that yet since finding the exact range is a touch on the slow
196           side.  (The advantage of which though is that it helps avoid very
197           big ranges from a simple over-estimate.)
198
199   Level Methods
200       "($n_lo, $n_hi) = $path->level_to_n_range($level)"
201           Return "(0, 5**$level)", or for multiple arms return "(0, $arms *
202           5**$level)".
203
204           There are 5^level + 1 points in a level, numbered starting from 0.
205           On the second and subsequent arms the origin is omitted (so as not
206           to repeat that point) and so just 5^level for them, giving
207           5^level+1 + (arms-1)*5^level = arms*5^level + 1 many points
208           starting from 0.
209

FORMULAS

211       Various properties are in my R5 Dragon mathematical write-up in section
212       "Quartet Curve",
213
214           <http://user42.tuxfamily.org/r5dragon/index.html>
215
216   X,Y to N
217       The current approach uses the "QuintetCentres" xy_to_n().  Because the
218       tiling in "QuintetCurve" and "QuintetCentres" is the same, the X,Y
219       coordinates for a given N are no more than 1 away in the grid.
220
221       The way the two lowest shapes are arranged in fact means that for a
222       "QuintetCurve" N at X,Y then the same N on the "QuintetCentres" is at
223       one of three locations
224
225           X, Y          same
226           X, Y+1        up
227           X-1, Y+1      up and left
228           X-1, Y        left
229
230       This is so even when the "arms" multiple paths are in use (the same
231       arms in both coordinates).
232
233       Is there an easy way to know which of the four offsets is right?  The
234       current approach is to give each to "QuintetCentres" to make an N, put
235       that N back through n_to_xy() to see if it's the target $n.
236

SEE ALSO

238       Math::PlanePath, Math::PlanePath::QuintetCentres,
239       Math::PlanePath::QuintetReplicate, Math::PlanePath::Flowsnake
240

HOME PAGE

242       <http://user42.tuxfamily.org/math-planepath/index.html>
243

LICENSE

245       Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
246       Kevin Ryde
247
248       This file is part of Math-PlanePath.
249
250       Math-PlanePath is free software; you can redistribute it and/or modify
251       it under the terms of the GNU General Public License as published by
252       the Free Software Foundation; either version 3, or (at your option) any
253       later version.
254
255       Math-PlanePath is distributed in the hope that it will be useful, but
256       WITHOUT ANY WARRANTY; without even the implied warranty of
257       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
258       General Public License for more details.
259
260       You should have received a copy of the GNU General Public License along
261       with Math-PlanePath.  If not, see <http://www.gnu.org/licenses/>.
262
263
264
265perl v5.36.0                      2023-01-20  Math::PlanePath::QuintetCurve(3)
Impressum