Not sure what I wanted to do with this, but I think this 2D version looks cool.
122,500 double pendulums start with initial angles ranging from -π to π.
This is quite nice. Does it show that the two angles do not get chaotic at the same rate? Initially I thought that the color of each pixel represents the angles… but when I zoomed I saw that these are actually thousands of miniature pendulums.
If you need ideas for future development, here are a few:
- Push the calculations down to the GPU, so that the simulation runs much faster/smoother
- Make triple pendulums (with transparency corresponding to the level of chaos, thus the peripherals areas will soon become more transparent, while the core near (0,0,0) will remain opaque longer)
- Add resonance or some form of passing energy from one pendulum to its neighbours; I’m not sure about the math behind this, but I’d expect this will generate waves that go through the pendulum continuum forward and backward
- Makes the strings elastic
- Make the pendulums swing in outer space with the mouse cursor being the gravity source - so the user can change the gravity source and observe how this affects the pendulums
Except for the first idea, I’m not sure whether the rest are worth persuading. It may turn out that the efforts are significant, but the results are not visually appealing.
I would say it demonstrates how chaotic initial conditions are. For each pendulum, the combination of the two angles (wrt to the y-axis) determine the color scheme.
In areas where the colors seem smooth or continuous, the system is less chaotic or less sensitive to initial conditions. When the colors become static or messy, it means neighboring pendulums have completely gone out of sync.
The main large “stability” area is near theta1 = 0 and theta2 = 0. What makes it a fractal is the presence of small islands of stability outside this big region. If you zoomed in on these tiny islands, you’d find even smaller ones, continuing indefinitely. (When zooming in tho you hit floating-point error limits pretty quickly) Also, pendulums that use these high-energy stable islands of condtions usually have cool symmetric motion.
These little outside islands of stability in this graphic almost look like grass blowing in the wind to me lol.
And those are great suggestions @PavelBoytchev! I think the GPU and mouse source one might make it my project list.
I use some of these high energy stable conditions here
double pendulum show case
This is amazing. A+
I created a GLSL version on ShaderToy. It works perfectly since a buffer can store only the four values, which is exactly what I need for this model (theta1
, dtheta1
, theta2
, and dtheta2
)
shadertoy link
My question is, can you use Three.js tools to solve these angles and then extract them from the shader code effiecntly, maybe using a uniform variable? Right now my data is stored in JS lists and JS solves the next angles, I guess in GPU code it would be stored in the “pixel” data… I know I can do some research on my own, but it’s something I haven’t tried yet.
yeah! Write the initial data into a THREE.DataTexture.
create 2 rendertargets
bind the dataTexture as a uniform for read…
set the output to rendertarget 0 and set it on the renderer… renderer.setRenderTarget(
in the shader… read the state from the state uniform…
apply/update/iterate the sim… write the new state out…
then bind rendertarget1 for write, and rendertarget0 for read and repeat as many times as your simulation needs…
when its done… read out the data with renderer.readRenderTargetPixels
Great! Thanks for the steps. If I get it, I’ll post it here.