Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created October 10, 2018 10:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SimonDanisch/d56e92f451497ba18db0dfbb1bab4b8e to your computer and use it in GitHub Desktop.
Save SimonDanisch/d56e92f451497ba18db0dfbb1bab4b8e to your computer and use it in GitHub Desktop.
growth(🐇, 🥕) = 🐇 * 🥕 * (1.0 - 🐇)
function orbitdiagram(growth, r1, r2, n = 500, a = zeros(1000, n); T = 1000)
rs = range(r1, stop = r2, length = 1000)
for (j, r) in enumerate(rs)
x = 0.5
for _ in 1:T; x = growth(x, r); end
for i in 1:n
x = growth(x, r)
@inbounds a[j, i] = x
end
end
rs, a
end
r1 = slider(0:0.001:4, raw = true)
r2 = slider(0:0.001:4, raw = true)
n1 = 500; n2 = 1000; a = zeros(n2, n1)
positions = Vector{Point2f0}(undef, n1 * n2)
pos = lift(r1[end][:value], r2[end][:value]) do r1, r2
global a
rs, a = orbitdiagram(growth, r1, r2, size(a, 2), a)
dim = size(a, 2)
for (i, r) in enumerate(rs)
positions[((i-1)*dim) + 1 : (i*dim)] .= Point2f0.(r, view(a, i, :))
end
positions
end
p = scatter(pos, markersize = 0.005, color = (:black, 0.4),limits = FRect3D(Vec3f0(0, 0, 0), Vec3f0(4, 1, 0)))
scene = hbox(
p,
vbox(r1, r2)
)
scene
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment