@@ -2,26 +2,29 @@ using IterTools
2
2
include (" SpiderFuncs.jl" )
3
3
include (" ../sequences/AngleDoubling.jl" )
4
4
5
- struct SpiderInfo
6
- orbit:: Vector{Rational}
7
- kneading_sequence:: Vector{Char}
8
- preperiod:: Int
5
+ struct Spider
6
+ angle:: Rational
7
+ orbit:: Sequence{Rational}
8
+ kneading_sequence:: Sequence{Char}
9
+ legs:: Vector{Vector{ComplexF64}}
9
10
end
10
-
11
11
12
- function SpiderInfo (theta:: Rational )
12
+ function Base. show (io:: IO , S:: Spider )
13
+ npoints = sum ([length (leg) for leg in S. legs])
14
+ return println (" A " * repr (S. angle)* " -spider with kneading sequence " * repr (S. kneading_sequence)* " and " * repr (npoints)* " points." )
15
+ end
13
16
17
+ function standardspider (theta:: Rational )
14
18
orb = orbit (theta)
15
- K = kneadingsequence (theta)
16
-
17
- return SpiderInfo (orb. items,K. items,K. preperiod)
18
-
19
+ K = thetaitinerary (theta,orb) # the kneading sequence is calculated like so to avoid recalculating the orbit of theta
20
+ legs = standardlegs (orb)
21
+ return Spider (theta,orb,K,legs)
19
22
end
20
23
21
- function standardlegs (SpIf :: SpiderInfo )
24
+ function standardlegs (orbit :: Sequence )
22
25
r = collect (LinRange (100 ,1 ,10 )) # NOTE - it may be better to keep this as a 'linrange' but I don't understand what that means
23
26
legs = Vector{ComplexF64}[]
24
- for theta in SpIf . orbit
27
+ for theta in orbit. items
25
28
push! (legs,(cos (theta* 2 * pi )+ 1.0im * sin (theta* 2 * pi )) .* r)
26
29
end
27
30
legs[1 ] = legs[1 ] .- legs[1 ][end ]
@@ -58,16 +61,16 @@ function stats(legs::Vector{Vector{ComplexF64}})
58
61
println (radius)
59
62
end
60
63
61
- function spidermap (S:: SpiderInfo , Legs :: Vector{Vector{ComplexF64}} )
62
- λ = Legs [2 ][end ] # the parameter of our polynomial map z -> λ(1+z/2)^2
63
- a = (angle (Legs [1 ][1 ]/ λ)/ (2 * pi )+ 1 )% 1 # the angle whose halves will define the boundary between regions A and B at infinity. in full turns
64
+ function mapspider! (S:: Spider )
65
+ λ = S . legs [2 ][end ] # the parameter of our polynomial map z -> λ(1+z/2)^2
66
+ a = (angle (S . legs [1 ][1 ]/ λ)/ (2 * pi )+ 1 )% 1 # the angle whose halves will define the boundary between regions A and B at infinity. in full turns
64
67
65
68
n = length (S. orbit)
66
69
67
70
newLegs = Vector {Vector{ComplexF64}} (undef,n)
68
71
69
72
# leg 1 goes first
70
- newLegs[1 ] = path_sqrt (Legs [2 ]. / λ)
73
+ newLegs[1 ] = path_sqrt (S . legs [2 ]. / λ)
71
74
72
75
theta1 = (angle (newLegs[1 ][1 ])/ (2 * pi )+ 1 )% 1 # gives the angle of the shoulder in full turns
73
76
# this angle lays in region A by definition.
@@ -82,75 +85,75 @@ function spidermap(S::SpiderInfo, Legs::Vector{Vector{ComplexF64}})
82
85
83
86
for ii in 2 : n- 1
84
87
# first find the right half plane preimage of the shoulder
85
- u = sqrt (Legs [ii+ 1 ][1 ]. / λ)
88
+ u = sqrt (S . legs [ii+ 1 ][1 ]. / λ)
86
89
thetau = (angle (u)/ (2 * pi )+ 1 )% 1
87
90
88
91
if a/ 2 < thetau && thetau < (a+ 1 )/ 2 # thetau is in the connected region
89
92
if S. kneading_sequence[ii] == cregion # then this is the correct preimage
90
- newLegs[ii] = path_sqrt (Legs [ii+ 1 ]. / λ)
93
+ newLegs[ii] = path_sqrt (S . legs [ii+ 1 ]. / λ)
91
94
else
92
- newLegs[ii] = - 1 .* path_sqrt (Legs [ii+ 1 ]. / λ)
95
+ newLegs[ii] = - 1 .* path_sqrt (S . legs [ii+ 1 ]. / λ)
93
96
end
94
97
else # thetau is in the disconnected region
95
98
if S. kneading_sequence[ii] == dregion # then this is the correct preimage
96
- newLegs[ii] = path_sqrt (Legs [ii+ 1 ]. / λ)
99
+ newLegs[ii] = path_sqrt (S . legs [ii+ 1 ]. / λ)
97
100
else
98
- newLegs[ii] = - 1 .* path_sqrt (Legs [ii+ 1 ]. / λ)
101
+ newLegs[ii] = - 1 .* path_sqrt (S . legs [ii+ 1 ]. / λ)
99
102
end
100
103
end
101
104
end
102
105
103
106
# we will break into periodic and preperiodic cases for the last leg
104
- if S. preperiod == 0 # periodic
105
- u = sqrt (Legs [1 ][1 ]. / λ)
107
+ if S. orbit . preperiod == 0 # periodic
108
+ u = sqrt (S . legs [1 ][1 ]. / λ)
106
109
thetau = (angle (u)/ (2 * pi )+ 1 )% 1
107
110
108
111
if abs2 (thetau - a/ 2 ) < abs2 (thetau - (a+ 1 )/ 2 )
109
112
if cregion == ' A'
110
- if S. kneading_sequence[end ] == ' 2'
111
- newLegs[end ] = path_sqrt (Legs [1 ]. / λ)
113
+ if S. kneading_sequence. items [end ] == ' 2'
114
+ newLegs[end ] = path_sqrt (S . legs [1 ]. / λ)
112
115
else
113
- newLegs[end ] = - 1 .* path_sqrt (Legs [1 ]. / λ)
116
+ newLegs[end ] = - 1 .* path_sqrt (S . legs [1 ]. / λ)
114
117
end
115
118
else
116
- if S. kneading_sequence[end ] == ' 1'
117
- newLegs[end ] = path_sqrt (Legs [1 ]. / λ)
119
+ if S. kneading_sequence. items [end ] == ' 1'
120
+ newLegs[end ] = path_sqrt (S . legs [1 ]. / λ)
118
121
else
119
- newLegs[end ] = - 1 .* path_sqrt (Legs [1 ]. / λ)
122
+ newLegs[end ] = - 1 .* path_sqrt (S . legs [1 ]. / λ)
120
123
end
121
124
end
122
125
else
123
126
if cregion == ' A'
124
- if S. kneading_sequence[end ] == ' 1'
125
- newLegs[end ] = path_sqrt (Legs [1 ]. / λ)
127
+ if S. kneading_sequence. items [end ] == ' 1'
128
+ newLegs[end ] = path_sqrt (S . legs [1 ]. / λ)
126
129
else
127
- newLegs[end ] = - 1 .* path_sqrt (Legs [1 ]. / λ)
130
+ newLegs[end ] = - 1 .* path_sqrt (S . legs [1 ]. / λ)
128
131
end
129
132
else
130
- if S. kneading_sequence[end ] == ' 2'
131
- newLegs[end ] = path_sqrt (Legs [1 ]. / λ)
133
+ if S. kneading_sequence. items [end ] == ' 2'
134
+ newLegs[end ] = path_sqrt (S . legs [1 ]. / λ)
132
135
else
133
- newLegs[end ] = - 1 .* path_sqrt (Legs [1 ]. / λ)
136
+ newLegs[end ] = - 1 .* path_sqrt (S . legs [1 ]. / λ)
134
137
end
135
138
end
136
139
end
137
140
138
141
else # preperiodic
139
142
p = S. preperiod
140
- u = sqrt (Legs [p+ 1 ][1 ]. / λ)
143
+ u = sqrt (S . legs [p+ 1 ][1 ]. / λ)
141
144
thetau = (angle (u)/ (2 * pi )+ 1 )% 1
142
145
143
146
if a/ 2 < thetau && thetau < (a+ 1 )/ 2 # thetau is in the connected region
144
- if S. kneading_sequence[end ] == cregion # then this is the correct preimage
145
- newLegs[end ] = path_sqrt (Legs [p+ 1 ]. / λ)
147
+ if S. kneading_sequence. items [end ] == cregion # then this is the correct preimage
148
+ newLegs[end ] = path_sqrt (S . legs [p+ 1 ]. / λ)
146
149
else
147
- newLegs[end ] = - 1 .* path_sqrt (Legs [p+ 1 ]. / λ)
150
+ newLegs[end ] = - 1 .* path_sqrt (S . legs [p+ 1 ]. / λ)
148
151
end
149
152
else # thetau is in the disconnected region
150
- if S. kneading_sequence[end ] == dregion # then this is the correct preimage
151
- newLegs[end ] = path_sqrt (Legs [p+ 1 ]. / λ)
153
+ if S. kneading_sequence. items [end ] == dregion # then this is the correct preimage
154
+ newLegs[end ] = path_sqrt (S . legs [p+ 1 ]. / λ)
152
155
else
153
- newLegs[end ] = - 1 .* path_sqrt (Legs [p+ 1 ]. / λ)
156
+ newLegs[end ] = - 1 .* path_sqrt (S . legs [p+ 1 ]. / λ)
154
157
end
155
158
end
156
159
end
@@ -161,18 +164,17 @@ function spidermap(S::SpiderInfo, Legs::Vector{Vector{ComplexF64}})
161
164
newLegs .*= (2.0 + 0.0im )
162
165
163
166
grow! (newLegs,10 ,10 )
164
-
165
- return newLegs
167
+ for ii in eachindex (S. legs)
168
+ S. legs[ii] = copy (newLegs[ii]) # done in this way so we can mutate S without mutating S
169
+ end
170
+ return S
166
171
end
167
172
168
- function spideriterate (angle:: Rational ,frames:: Int )
169
- info = SpiderInfo (angle)
170
-
171
- list = [standardlegs (angle)]
173
+ function spideriterates (S0:: Spider ,n_iter:: Int )
174
+ list = [deepcopy (S0)]
172
175
173
- for i in 1 : frames- 1
174
- SL = list[end ]
175
- push! (list,spidermap (info,SL))
176
+ for i in 1 : n_iter
177
+ push! (list,deepcopy (mapspider! (S0)))
176
178
end
177
- return list[ end ][ 2 ][ end ] / 2
179
+ return list
178
180
end
0 commit comments