Skip to content

Instantly share code, notes, and snippets.

@SimonDanisch
Created August 1, 2018 17:24
Show Gist options
  • Save SimonDanisch/bb9c44b96845377b8899cb70a598bbd3 to your computer and use it in GitHub Desktop.
Save SimonDanisch/bb9c44b96845377b8899cb70a598bbd3 to your computer and use it in GitHub Desktop.
using Makie, Colors
using AbstractPlotting: modelmatrix
scene = Scene(resolution = (1000, 1000))
AbstractPlotting.set_theme!()
ui_width = 260
ui = Scene(scene, lift(x-> IRect(0, 0, ui_width, widths(x)[2]), pixelarea(scene)))
plot_scene = Scene(scene, lift(x-> IRect(ui_width, 0, widths(x) .- Vec(ui_width, 0)), pixelarea(scene)))
theme(ui)[:plot] = NT(raw = true)
campixel!(ui)
translate!(ui, 10, 50, 0)
a = textslider(ui, 0f0:50f0, "a")
b = textslider(ui, -20f0:20f0, "b")
c = textslider(ui, 0f0:20f0, "c")
d = textslider(ui, linspace(0.0, 0.01, 100), "d")
scales = textslider(ui, linspace(0.01, 0.5, 100), "scale")
color, pop = colorswatch(ui)
hbox!(ui.plots)
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
n1, n2 = 18, 30
N = n1*n2
args_n = (a, b, c, d)
args = (13f0, 10f0, 2f0, 0.01f0)
setindex!.(args_n, args)
v0 = lorenz(zeros(Point3f0, N), args...)
positions = Reactive.foldp(lorenz, v0, args_n...)
rotations = lift(diff, positions)
rotations = lift(x-> push!(x, x[end]), rotations)
plot = meshscatter!(
plot_scene,
positions,
#marker = Makie.loadasset("cat.obj"),
markersize = scales, rotation = rotations,
intensity = collect(linspace(0f0, 1f0, length(positions[]))),
color = color
)
scene
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment