1Math::PlanePath::CompleUxsPelrusC(o3n)tributed Perl DocuMmaetnht:a:tPiloannePath::ComplexPlus(3)
2
3
4
6 Math::PlanePath::ComplexPlus -- points in complex base i+r
7
9 use Math::PlanePath::ComplexPlus;
10 my $path = Math::PlanePath::ComplexPlus->new;
11 my ($x, $y) = $path->n_to_xy (123);
12
14 This path traverses points by a complex number base i+r for integer
15 r>=1. The default is base i+1
16
17 30 31 14 15 5
18 28 29 12 13 4
19 26 27 22 23 10 11 6 7 3
20 24 25 20 21 8 9 4 5 2
21 62 63 46 47 18 19 2 3 1
22 60 61 44 45 16 17 0 1 <- Y=0
23 58 59 54 55 42 43 38 39 -1
24 56 57 52 53 40 41 36 37 -2
25 50 51 94 95 34 35 78 79 -3
26 48 49 92 93 32 33 76 77 -4
27 90 91 86 87 74 75 70 71 -5
28 88 89 84 85 72 73 68 69 -6
29 126 127 110 111 82 83 66 67 -7
30 124 125 108 109 80 81 64 65 -8
31 122 123 118 119 106 107 102 103 -9
32 120 121 116 117 104 105 100 101 -10
33 114 115 98 99 -11
34 112 113 96 97 -12
35
36 ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
37 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 X=0 1 2
38
39 The shape of these points N=0 to N=2^k-1 inclusive is equivalent to the
40 twindragon turned 135 degrees. Each complex base point corresponds to
41 a unit square inside the twindragon curve (two DragonCurve back-to-
42 back).
43
44 Real Part
45 Option "realpart => $r" selects another r for complex base b=i+r. For
46 example
47
48 realpart => 2
49 45 46 47 48 49 8
50 40 41 42 43 44 7
51 35 36 37 38 39 6
52 30 31 32 33 34 5
53 25 26 27 28 29 20 21 22 23 24 4
54 15 16 17 18 19 3
55 10 11 12 13 14 2
56 5 6 7 8 9 1
57 0 1 2 3 4 <- Y=0
58
59 ^
60 X=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
61
62 N is broken into digits of a base norm=r*r+1, ie. digits 0 to r*r
63 inclusive.
64
65 norm = r*r + 1
66 Nstart = 0
67 Nlevel = norm^level - 1
68
69 The low digit of N makes horizontal runs of r*r+1 many points, such as
70 N=0 to N=4, then N=5 to N=9, etc shown above. In the default r=1 these
71 runs are 2 long. For r=2 shown above they're 2*2+1=5 long, or r=3
72 would be 3*3+1=10, etc.
73
74 The offset for each successive run is i+r, ie. Y=1,X=r such as at N=5
75 shown above. Then the offset for the next level is (i+r)^2 = (2r*i +
76 r^2-1) so N=25 begins at Y=2*r=4, X=r*r-1=3. In general each level
77 adds an angle
78
79 angle = atan(1/r)
80 Nlevel_angle = level * angle
81
82 So the points spiral around anti-clockwise. For r=1 the angle is
83 atan(1/1)=45 degrees, so that for example level=4 is angle 4*45=180
84 degrees, putting N=2^4=16 on the negative X axis as shown in the first
85 sample above.
86
87 As r becomes bigger the angle becomes smaller, making it spiral more
88 slowly. The points never fill the plane, but the set of points N=0 to
89 Nlevel are all touching.
90
91 Arms
92 For "realpart => 1", an optional "arms => 2" adds a second copy of the
93 curve rotated 180 degrees and starting from X=0,Y=1. It meshes
94 perfectly to fill the plane. Each arm advances successively so
95 N=0,2,4,etc is the plain path and N=1,3,5,7,etc is the copy
96
97 arms=>2
98
99 60 62 28 30 5
100 56 58 24 26 4
101 52 54 44 46 20 22 12 14 3
102 48 50 40 42 16 18 8 10 2
103 36 38 3 1 4 6 35 33 1
104 32 34 7 5 0 2 39 37 <- Y=0
105 11 9 19 17 43 41 51 49 -1
106 15 13 23 21 47 45 55 53 -2
107 27 25 59 57 -3
108 31 29 63 61 -4
109
110 ^
111 -6 -5 -4 -3 -2 -1 X=0 1 2 3 4 5 6
112
113 There's no "arms" parameter for other "realpart" values as yet, only
114 for i+1. Is there a good rotated arrangement for others? Do "norm"
115 many copies fill the plane in general?
116
118 See "FUNCTIONS" in Math::PlanePath for behaviour common to all path
119 classes.
120
121 "$path = Math::PlanePath::ComplexPlus->new ()"
122 Create and return a new path object.
123
124 "($x,$y) = $path->n_to_xy ($n)"
125 Return the X,Y coordinates of point number $n on the path. Points
126 begin at 0 and if "$n < 0" then the return is an empty list.
127
128 Level Methods
129 "($n_lo, $n_hi) = $path->level_to_n_range($level)"
130 Return "(0, 2**$level - 1)", or for 2 arms return "(0, 2 *
131 2**$level - 1)". With the "realpart" option return "(0,
132 $norm**$level - 1)" where norm=realpart^2+1.
133
135 Various formulas and pictures etc for the i+1 case can be found in the
136 author's long mathematical write-up (section "Complex Base i+1")
137
138 <http://user42.tuxfamily.org/dragon/index.html>
139
141 Entries in Sloane's Online Encyclopedia of Integer Sequences related to
142 this path include
143
144 <http://oeis.org/A290885> (etc)
145
146 realpart=1 (i+1, the default)
147 A290885 -X
148 A290884 Y
149 A290886 norm X^2 + Y^2
150 A146559 dX at N=2^k-1 (step to next replication level)
151 A077950,A077870
152 location of ComplexMinus origin in ComplexPlus
153 (mirror horizontal even level, vertical odd level)
154
156 Math::PlanePath, Math::PlanePath::ComplexMinus,
157 Math::PlanePath::ComplexRevolving, Math::PlanePath::DragonCurve
158
159 <http://user42.tuxfamily.org/dragon/index.html>
160
162 <http://user42.tuxfamily.org/math-planepath/index.html>
163
165 Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020
166 Kevin Ryde
167
168 This file is part of Math-PlanePath.
169
170 Math-PlanePath is free software; you can redistribute it and/or modify
171 it under the terms of the GNU General Public License as published by
172 the Free Software Foundation; either version 3, or (at your option) any
173 later version.
174
175 Math-PlanePath is distributed in the hope that it will be useful, but
176 WITHOUT ANY WARRANTY; without even the implied warranty of
177 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
178 General Public License for more details.
179
180 You should have received a copy of the GNU General Public License along
181 with Math-PlanePath. If not, see <http://www.gnu.org/licenses/>.
182
183
184
185perl v5.32.1 2021-01-27 Math::PlanePath::ComplexPlus(3)