block by monfera 1faaeec4a33cfd3270bb8e44f0d7fb2e

Brownian motion with elastic collisions

Full Screen

This block uses Toph Tucker’s elastic collision, otherwise identical with the previous Brownian motion example.

Particle collisions are more accurately modeled as elastic collisions and the results look more convincing. Also it shows that the quadtree based elastic force implementation looks as fast as the inelastic collision in D3.

================

Brownian motion is observable when dust particles (here: red) follow random, erratic paths as they are pushed around by the invisibly small, but fast and numerous gas atoms or molecules. It’s not only of interest in natural sciences but is also the keystone in quantitative finance.

It’s initially hard to see how the small, fast particles impact the larger dust speckles, but in a minute or so the temperature cools and things slow down.

This Brownian motion example shows physics capabilities of the versatile d3.forceSimulation in D3 4.0 which now uses velocity Verlet integration.

D3 simulated forces are kept to a minimum: besides d3.forceCollide the only other force ensures that particles are not lost in space (perfectly bouncy walls of identical temperature).

A slow cooling is simulated by using a small non-zero value as velocityDecay.

Rendering is done on two superimposed <canvas> layers such that one can be continuously erased while the other shows a historical snail trail as if drawn with marker on a glass plane.

Built with blockbuilder.org

forked from monfera‘s block: Brownian motion with D3 4.0 velocity Verlet physics

index.html