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                   125--...                 93--92                      11
18                     |                       |   |
19               123-124                      94  91--90--89--88          10
20                 |                           |               |
21               122-121-120 103-102          95  82--83  86--87           9
22                         |   |   |           |   |   |   |
23               115-116 119 104 101-100--99  96  81  84--85               8
24                 |   |   |   |           |   |   |
25           113-114 117-118 105  32--33  98--97  80--79--78               7
26             |               |   |   |                   |
27           112-111-110-109 106  31  34--35--36--37  76--77               6
28                         |   |   |               |   |
29                       108-107  30  43--42  39--38  75                   5
30                                 |   |   |   |       |
31                        25--26  29  44  41--40  73--74                   4
32                         |   |   |   |           |
33                    23--24  27--28  45--46--47  72--71--70--69--68       3
34                     |                       |                   |
35                    22--21--20--19--18  49--48  55--56--57  66--67       2
36                                     |   |       |       |   |
37                     5---6---7  16--17  50--51  54  59--58  65           1
38                     |       |   |           |   |   |       |
39             0---1   4   9---8  15          52--53  60--61  64       <- Y=0
40                 |   |   |       |                       |   |
41                 2---3  10--11  14                      62--63          -1
42                             |   |
43                            12--13                                      -2
44
45             ^
46            X=0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 ...
47
48       As per
49
50           Benoit B. Mandelbrot, "The Fractal Geometry of Nature", W. H. Freeman
51           and Co., 1983, ISBN 0-7167-1186-9, section 7, "Harnessing the Peano
52           Monster Curves", pages 72-73.
53
54       Mandelbrot calls this a "quartet", taken as 4 parts around a further
55       middle part (like 4 players around a table).  The module name "quintet"
56       here is a mistake, though it does suggest the base-5 nature of the
57       curve.
58
59       The base figure is the initial N=0 to N=5.
60
61                     5
62                     |
63                     |
64             0---1   4      base figure
65                 |   |
66                 |   |
67                 2---3
68
69       It corresponds to a traversal of the following "+" shape,
70
71                .... 5
72                .    |
73                .   <|
74                     |
75           0----1 .. 4 ....
76             v  |    |    .
77           .    |>   |>   .
78           .    |    |    .
79           .... 2----3 ....
80                . v  .
81                .    .
82                .    .
83                . .. .
84
85       The "v" and ">" notches are the side the figure is directed at the
86       higher replications.  The 0, 2 and 3 sub-curves are the right hand side
87       of the line and are a plain repetition of the base figure.  The 1 and 4
88       parts are to the left and are a reversal.  The first such reversal is
89       seen in the sample above as N=5 to N=10.
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,
154
155                       +---+
156                       |   |
157               +---@---    +---+
158               |   |     B     |
159           +---+   +---+   +---@
160           |     C     |   |   |
161           +---+   +---O---+   +---+
162               |   |   |     A     |
163               @---+   +---+   +---+
164               |     D     |   |
165               +---+   +---@---+
166                   |   |
167                   +---+
168
169       At higher replication levels the sides are wiggly and spiralling and
170       the centres of each rotate around, but their sides are symmetric and
171       mesh together perfectly to fill the plane.
172

FUNCTIONS

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

FORMULAS

210   X,Y to N
211       The current approach uses the "QuintetCentres" "xy_to_n()".  Because
212       the tiling in "QuintetCurve" and "QuintetCentres" is the same, the X,Y
213       coordinates for a given N are no more than 1 away in the grid.
214
215       The way the two lowest shapes are arranged in fact means that for a
216       "QuintetCurve" N at X,Y then the same N on the "QuintetCentres" is at
217       one of three locations
218
219           X, Y          same
220           X, Y+1        up
221           X-1, Y+1      up and left
222           X-1, Y        left
223
224       This is so even when the "arms" multiple paths are in use (the same
225       arms in both coordinates).
226
227       Is there an easy way to know which of the four offsets is right?  The
228       current approach is to give each to "QuintetCentres" to make an N, put
229       that N back through "n_to_xy()" to see if it's the target $n.
230

SEE ALSO

232       Math::PlanePath, Math::PlanePath::QuintetCentres,
233       Math::PlanePath::QuintetReplicate, Math::PlanePath::Flowsnake
234

HOME PAGE

236       <http://user42.tuxfamily.org/math-planepath/index.html>
237

LICENSE

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