57

GitHub - portsmouth/fibre: WebGL 3d dynamical systems visualization

 5 years ago
source link: https://github.com/portsmouth/fibre
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md

Fibre

Fibre is a WebGL application for visualizing and coding 3d vector fields and dynamical systems. A number of presets with well-known or interesting dynamical systems are provided as below (click to launch). New vector fields can be authored in the code editor, and shared via an HTML link with the embedded code.

Aizawa.pngArneodo.pngBouali.pngChen_Lee.png dipole.pngHadley.pngHalvorsen.pngLiu_Chen.png Lorenz.pngNewton_Leipnik.pngNose_Hoover.pngquadrupole.png Rayleigh_Benard.pngRossler.pngRucklidge.pngSakarya.png Shimizu_Morioka.pngSprott_Linz.pngThomas.pngTSUCS1.png

In three (or more) dimensions, a non-linear continuous dynamical system may exhibit chaos, which is characterised by sensitive dependence of the solution trajectories to the initial conditions, and evolution governed by a so-called "strange attractor". Probably the most famous example is the Lorenz system, initially discovered as a simplified model of atmospheric convection:

68747470733a2f2f6c617465782e636f6465636f67732e636f6d2f6769662e6c617465783f5c626567696e7b61727261797d7b72636c7d2673706163653b5c667261637b5c6d617468726d7b64787d7d7b64747d2673706163653b263d262673706163653b5c7369676d612673706163653b28792673706163653b2d2673706163653b78292673706163653b5c7673706163657b302e31636d7d5c5c2673706163653b5c667261637b5c6d617468726d7b64797d7d7b64747d2673706163653b263d262673706163653b782673706163653b285c72686f2673706163653b2d2673706163653b7a292673706163653b2d2673706163653b792673706163653b5c7673706163657b302e31636d7d5c5c2673706163653b5c667261637b5c6d617468726d7b647a7d7d7b64747d2673706163653b263d262673706163653b78792673706163653b2d2673706163653b5c626574612673706163653b7a2673706163653b5c7673706163657b302e31636d7d5c5c2673706163653b5c656e647b61727261797d

whose solution curves (x(t), y(t), z(t)), starting from any initial point (x(0), y(0), z(0)), tend to the Lorenz strange attractor.

In general, a three-dimensional continuous dynamical system is a system of first order ordinary differential equations (ODE) of the form below, where the functions on the right hand side define a vector field giving the velocity vector of the dynamical system at each point in space (and, optionally, time):

68747470733a2f2f6c617465782e636f6465636f67732e636f6d2f6769662e6c617465783f5c626567696e7b61727261797d7b72636c7d2673706163653b5c667261637b5c6d617468726d7b64787d7d7b64747d2673706163653b263d262673706163653b765f7828782c2673706163653b792c2673706163653b7a2c2673706163653b74292673706163653b5c7673706163657b302e31636d7d5c5c2673706163653b5c667261637b5c6d617468726d7b64797d7d7b64747d2673706163653b263d262673706163653b765f7928782c2673706163653b792c2673706163653b7a2c2673706163653b74292673706163653b5c7673706163657b302e31636d7d5c5c2673706163653b5c667261637b5c6d617468726d7b647a7d7d7b64747d2673706163653b263d262673706163653b765f7a28782c2673706163653b792c2673706163653b7a2c2673706163653b74292673706163653b5c7673706163657b302e31636d7d5c5c2673706163653b5c656e647b61727261797d

In Fibre, the code editor on the left specifies this velocity vector field via the GLSL function vec3 velocity(vec3 p, float t) . Additionally, a color at each point in space must be specified via vec3 color(vec3 p, float t). The system then traces the solution curves of the ODE (using the Runge-Kutta method), starting from a grid of points covering the "initial conditions box" positioned in the viewport. These curves are rendered as colored tubes. (Note, the tubes are not rendered as geometry, they consist of many individual line segments, which are progressively rendered and blended over a number of iterations in order to converge to the final image).

UI controls:

  • left-click mouse to rotate, right-click mouse to pan camera
  • hover over the initial conditions box and left-click to drag it around, or hover over the box corners and left-click to resize the box dimensions. The box extents can also be edited directly in the Integrator rollout of the UI.
  • the first (green) ☰ button hides/shows the code editor, in which the velocity vector field and color field are defined as GLSL functions.
  • editing the GLSL code immediately updates the shader -- if there is an error, this will be copied to the viewport, and rendering terminated
  • click on values in the code editor to pop up a slider which scrubs the value
  • click on colors (e.g. rgb(255, 0, 0)) in the code editor to pop up a color wheel
  • The second (blue) ☰ button generates a data URL which can be used to save and share the current vector field. Note that the URL itself contains the full state of the application, including the GLSL code, all the UI settings, and the camera and initial conditions box. So this link can be used to share the exact state of the application with anyone else (e.g. on Twitter).
  • AWSD keys to fly
  • C key to frame camera on the initial conditions box
  • P key to capture a screenshot of the current render in a new browser window
  • H key to hide/show the sidebar UI
  • F11 key to enter/exit fullscreen mode

Integration parameters

  • gridSpace: the spacing between start points within the initial conditions box, relative to the box maximum extents
  • tubeWidth: the radius of the rendered solution tubes, relative to the box maximum extents
  • integrationTime: the total time to integrate over
  • maxTimeSteps: the number of timesteps into which the integrationTime is broken into
  • xmin: (etc.) initial conditions box bounds
  • clipToBounds: renders only the portion of the solution curves which lies within the initial conditions box
  • integrateForward: if selected, integrate over positive times i.e. the time interval [0, integrationTime], otherwise integrate over the time interval [-integrationTime/2, integrationTime/2]
  • enableBounds: if disabled, the initial conditions box is locked (allowing the camera to be moved within the box)

Rendering parameters

  • showBounds: whether to show the initial conditions box bounds
  • exposure: controls overall brightness of image
  • gamma: controls gamma correction factor of image
  • contrast: controls image contrast
  • saturation: controls image saturation
  • fov: change the camera field-of-view
  • hairShader: use a simple hair shading model for the specular component (otherwise uses the Blinn-Phong model)
  • specShine: controls size of tube specular highlight
  • specColor: the color of the specular highlight (blended with the diffuse tube color defined in the code)
  • depthTest: controls whether tubes are opaque or blended

Advanced parameters

  • rayBatch: the number of ray segments to render in one iteration (higher means convergence in less iterations, but slower iterations)
  • maxIterations: the max iteration count, beyond which the render terminates. Increase this to improve the final image quality.
  • subtractiveColor: treat the colors as absorption coefficients
  • bgColor: change color of background (probably use in conjunction with subtractiveColor)
  • light1_color: the color of the first light, used to modulate the diffuse reflectance from the tubes
  • light2_color: the color of the second light, used to modulate the diffuse reflectance from the tubes
  • light1_dir: the direction of the first light, used to modulate the diffuse reflectance from the tubes
  • light2_dir: the direction of the second light, used to modulate the diffuse reflectance from the tubes
  • dashes: enable animated dashes showing the direction of flow (must use in conjunction with depthTest)
  • dash_spacing: space between animated dashes, relative to gridSpace
  • dash_size: fractional size of dash, in [0, 1]
  • dash_speed: rate of dash motion, in dashes per second
  • RECORD: start/stop recording a GIF of the viewport interaction
  • RECORD PERIOD: record a GIF of one dash period (for repeating GIFs of the animated dash motion)
  • record_realtime: whether to record the real-time interaction to the GIF, or at the maximum frame-rate
  • RENDER ANIM: start recording a GIF of a number of automatically rendered animated frames (the number specified via anim_frames). Each frame renders for the number of iterations specified via maxIterations. The camera can optionally (via anim_enable_turntable) be moved in a turntable motion through a specified number of degrees anim_turntable_degrees during the animation. The uniform float variable animFraction is available in the shader, which equals the number of elapsed frames divided by the total number of frames. At the end of the animation, a GIF is rendered (which may take some time) and saved to the downloads folder with a standard name.
  • CANCEL ANIM: cancel the current animation recording
  • anim_frames: how many animation frames to render in the generated GIF
  • anim_enable_turntable: whether to move the camera in a turntable sweep motion during the animation
  • anim_turntable_degrees: if turntable is enabled, how many degrees to rotate through

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK