Created
December 3, 2018 17:51
-
-
Save SimonDanisch/b438280092238f766ac0436e504c9295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AbstractPlotting.set_theme!() # reset theme | |
function lorenz(t0, a, b, c, h) | |
Point3f0( | |
t0[1] + h * a * (t0[2] - t0[1]), | |
t0[2] + h * (t0[1] * (b - t0[3]) - t0[2]), | |
t0[3] + h * (t0[1] * t0[2] - c * t0[3]), | |
) | |
end | |
# step through the `time` | |
function lorenz(array::Vector, a = 5.0 ,b = 2.0, c = 6.0, d = 0.01) | |
t0 = Point3f0(0.1, 0, 0) | |
for i = eachindex(array) | |
t0 = lorenz(t0, a,b,c,d) | |
array[i] = t0 | |
end | |
array | |
end | |
a = slider(0f0:50f0, label = "a", value = 13) | |
b = slider(-20f0:20f0, label = "b", value = 10) | |
c = slider(0f0:20f0, label = "c", value = 2) | |
d = slider(LinRange(0.0, 0.02, 100), label = "d", value = 0.01676) | |
scales = slider(LinRange(0.01, 0.5, 100), label = "scale", start = 0.1) | |
rotation = slider(LinRange(0, 2pi, 360), label = "rotation") | |
mcolor = widget(colorant"red") | |
n1, n2 = 18, 30 | |
N = n1*n2 | |
args_n = observe.((a, b, c, d)) | |
v0 = lorenz(zeros(Point3f0, N), to_value.(args_n)...) | |
positions = lift(lorenz, Makie.Node(v0), args_n...) | |
mscene = meshscatter( | |
positions, | |
markersize = scales, | |
intensity = collect(range(0f0, stop = 1f0, length = length(positions[]))), | |
color = mcolor, center = false | |
) | |
center!(mscene) | |
lastval = Ref(rotation[]) | |
on(rotation) do x | |
global lastval | |
rotate_cam!(mscene, lastval[] - x, 0.0, 0.0) | |
lastval[] = x | |
end | |
upsignal = Observables.async_latest(lift(positions, observe(rotation), mcolor, observe(scales)) do a... | |
end) | |
up_scene = lift(x-> Makie.GLMakie.scene2image(mscene), upsignal) | |
CSSUtil.vbox(a, b, c, d, scales, rotation, mcolor, up_scene) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment