Wasn't too sure where to post this, but this repo seems to curate d3-force plugins for use in (perhaps) unusual use-cases, like physical simulations - so figured I'd alert users to energy-conservation in d3-force.
@gvarnavi this is awesome research, great work! I think it's well worth to post this on the https://github.com/d3/d3-force repo for broader visibility.
Wasn't too sure where to post this, but this repo seems to curate d3-force plugins for use in (perhaps) unusual use-cases, like physical simulations - so figured I'd alert users to energy-conservation in d3-force.
In particular, the Pendulum example asks:
Similarly, the Newton's Cradle example also 'thermalizes' albeit both explicitly setting:
The issue is that d3.forceLink actually performs iterative relaxation. The offending lines in the source code are:
Note the link distance is specified by 'peeking ahead' to the anticipated position of the node ⟨x + vx,y + vy⟩.
This notebook further explains the issue using examples, and suggests two alternatives.