jamportz
That’s a good idea, will try it.
Looking at the source code, indeed many of the magnetic fields are computed via the Biot-Savart law, though some interesting ones are not. I might try rendering them.
I'm not sure it's easy to implement this though, as it requires first solving for the equilibrium points of the flow, which in general requires solving a set of non-linear equations. That could maybe be attempted numerically, but it's likely to be difficult to make it fast/robust (not to mention, to implement it at all in WebGL shaders).
Also, in three dimensions are the separatrices still lines, or they can also be 2d surfaces? I'm not sure how they would be rendered if they can live on surfaces
https://twitter.com/jamportz/status/1079777103892135936 https://tinyurl.com/y859v78t
For magnetic fields, the problem is there are no simple (non-trivial) solutions for the magnetic fields of interesting things like a bar magnet. Even the magnetic field of a circular loop of current involves elliptic integrals. (see e.g. https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/200100...).
What you could do is numerically solve the https://en.wikipedia.org/wiki/Biot%E2%80%93Savart_law (given your currents) inside the GLSL shader.. Though this will probably be very slow..
I'm not sure it will be usable anyway on a mobile device (https://github.com/dataarts/dat.gui is not very mobile friendly, and it requires too much fine control for fingers I think).
https://en.wikipedia.org/wiki/Integral_curve
You can think of the vector field as the definition of a differential equation, i.e. it gives the rate of change of each coordinate at each point. The solution of the differential equation, given a start point, is then some curve, which is locally tangent to the vector field at every point.
I think one is usually more interested in the solution curves than in the vector field itself, particularly in 3d. As the vector field itself would render as a cloud of little isolated lines which don't reveal much structure, whereas the solution curves show a lot of structure (for sufficiently dense lines, forming 3d structures like ribbons, sheets, helices, etc.).
In 2d, one can get away with rendering little arrows and still produce a decent looking visualization, e.g. https://github.com/anvaka/fieldplay (which I would agree, is a genuine "vector field renderer").
Agreed it needs some optimization. The reason the attractor gets recalculated when rotating, is that there is actually no geometry at all..
This is different from the approach used in e.g. https://syntopia.github.io/StrangeAttractors/, where the Runge-Kutta integration is done is JS and converted to geo. The advantage of that approach is that the rotation is smooth (and there is no shader recompilation), but the number of lines/tubes is limited by the time for JS to do the RK integration.
In my approach, the image is generated fresh from each viewpoint as follows: - initialize a floating point texture A with the start points - in a shader, update all points in parallel to their next position, via R-K, writing to texture B - draw all of the GL line segments via a vertex shader which reads the line endpoints from the textures A and B (with lighting done in the line fragment shader) - composite the result into the framebuffer - repeat for the number of integration timesteps, ping-ponging A/B - iterate over frames, with the start points jittered, blending each frame equally
This renders the thick tubes over time.
This way the integration happens entirely in shaders, with JS never seeing any geometry. So a really huge effective amount of geometry can be rendered (billions of lines?). The disadvantage is that the integration is re-done for every viewpoint, and also the GLSL shader is recompiled whenever the vector field changes. I was optimizing here for detail of the visualization more than for smoothness of the interaction -- but I would like to improve the interactivity for sure.
(There's no web workers involved -- except during GIF rendering, with uses the very nice lib https://jnordberg.github.io/gif.js/).
>It could use better controls for changing the attractor constants. Changing those constants can really give you a good feeling of what chaos and strange attractors really are.
>Some of the controls also feel a bit hard to handle, you might want to look into doing custom controls or looking at UX a bit more.
I'm keen to know where I can improve the controls. For the number/color scrubbing in the code editor I just use http://enjalot.github.io/Inlet/ pretty much out-of-the-box. It does seems a little clunky, though generally I really like the notion of the UI being integrated with the code like this.