Skip to content

Commit 488a521

Browse files
committed
phonebook of internal addresses
1 parent 549482b commit 488a521

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

interactive.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function colorax(ax)
77
hidedecorations!(ax)
88
hidespines!(ax)
99
deactivate_interaction!(ax, :rectanglezoom)
10-
#deactivate_interaction!(ax, :dragpan)
10+
deactivate_interaction!(ax, :dragpan)
1111
#deactivate_interaction!(ax, :scrollzoom)
1212

1313
sg = SliderGrid(fig[2,1],

sequences/AngleDoubling.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,25 @@ function denominators(S::Vector{Int})
255255
return q
256256
end
257257

258+
function denominator(AIA::AngledInternalAddress,new::Int)
259+
K = kneadingsequence(AIA.addr)
260+
p = rhoSequence(K)
261+
262+
r = mod1(new,AIA.addr[end])
263+
orb = p(r)
264+
265+
if AIA.addr[end] in orb
266+
qk = Int((new - r)/AIA.addr[end] + 1) #why is this always an integer?
267+
268+
else
269+
qk = Int((new - r)/AIA.addr[end] + 2)
270+
271+
end
272+
273+
return qk
274+
end
275+
276+
258277
function numembeddings(I::Vector{Int})
259278
D = denominators(I)
260279
n = 1

sequences/Phonebook.jl

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
using GLMakie
2+
include("AngleDoubling.jl")
3+
4+
#for each internal address, calculate a screen which shows the future options
5+
6+
function drawwedges!(ax,AIA)
7+
N = AIA.addr[end]
8+
n = 5
9+
for ii in N+1:N+n
10+
k = denominator(AIA,ii)
11+
angles = []
12+
for jj in 1:k-1
13+
if gcd(jj,k) == 1
14+
push!(angles,(jj-0.5)*2*pi/(k-1))
15+
end
16+
end
17+
r = (2^ii+2^(ii-1))/2
18+
centers = [(r*cos(theta),r*sin(theta)) for theta in angles]
19+
pie!(ax,ones(k-1),radius = 2^ii, inner_radius = 2^(ii-1))
20+
text!(ax,centers,text = fill("$ii",length(centers)), align = (:center,:center))
21+
end
22+
end
23+
24+
function phonebook!(gl,AIA)
25+
label = Label(gl[2,1],repr(AIA[]))
26+
rowsize!(gl, 1, Aspect(1, 1.0))
27+
ax1 = Axis(gl[1,1],aspect = 1)
28+
drawwedges!(ax1,AIA[])
29+
30+
hidedecorations!(ax1)
31+
hidespines!(ax1)
32+
deactivate_interaction!(ax1, :rectanglezoom)
33+
deactivate_interaction!(ax1, :dragpan)
34+
35+
register_interaction!(ax1, :select) do event::MouseEvent, ax1
36+
if event.type === MouseEventTypes.leftdown
37+
ang = atan(event.data[2],event.data[1])
38+
rad = sqrt(sum([x*x for x in event.data]))
39+
idx = Int(ceil(log2(rad)))
40+
if idx > 0
41+
k = denominator(AIA[],idx)
42+
num = Int(mod1(ceil(ang*(k-1)/(2*pi)),k-1))
43+
println("$idx and $num / $k")
44+
if gcd(num,k) == 1
45+
newaddr = push!(copy(AIA[].addr),idx)
46+
newangles = push!(copy(AIA[].angles),Rational(num,k))
47+
AIA[] = AngledInternalAddress(newaddr,newangles)
48+
println(AIA[])
49+
empty!(ax1)
50+
drawwedges!(ax1,AIA[])
51+
label.text = repr(AIA[])
52+
end
53+
end
54+
end
55+
end
56+
57+
58+
59+
end
60+
61+
62+
fig = Figure()
63+
ga = fig[1, 1] = GridLayout()
64+
65+
AIA = Observable(AngledInternalAddress([1],[]))
66+
67+
phonebook!(ga,AIA)
68+
69+
fig

0 commit comments

Comments
 (0)