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
Updated missing url https://rawgit.com/tophtucker/16fbd7e7c6274ed329111cbe139a6bb6/raw/d6daaf1e9e3914268e2df1837bacf26622802e21/forceCollideElastic.js to https://cdn.jsdelivr.net/gh/tophtucker/16fbd7e7c6274ed329111cbe139a6bb6/raw/d6daaf1e9e3914268e2df1837bacf26622802e21/forcecollideelastic.js
https://d3js.org/d3.v4.min.js
https://rawgit.com/tophtucker/16fbd7e7c6274ed329111cbe139a6bb6/raw/d6daaf1e9e3914268e2df1837bacf26622802e21/forceCollideElastic.js