Collisions between nodes
Based on this example but enhanced to accurately model relative "mass" the rebound velocities are solved for using the equations for conservation of momentum and conservation of energy. The "efficiency" of the collisions - as defined by the ratio of the actual final velocities divided by the ideal, perfectly elastic system - is set internally.
Boundary constraints and collisions
This behaviour is also included in the gravity
function and uses basic geometry to reflect the incident velocity in the plane of the boundary. It does this by using the Node velocity API to manipulate the d.px
and d.py
values of the nodes. It is possible, however, for nodes to penetrate the boundaries due to limitations in the temporal resolution of the layout.
Recovering escaped nodes
If a node escapes the boundaries of the bounding box, the velocity is still reflected in the plane of the penetrated boundary. If the escaped node's normal velocity component is zero then the node is steered back toward the boundary, with constant speed.
Updated missing url https://gitcdn.xyz/repo/cool-Blue/d3-lib/master/filters/shadow.js to https://cdn.jsdelivr.net/gh/repo/cool-blue/d3-lib/filters/shadow.js
https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
https://cdnjs.cloudflare.com/ajax/libs/pixi.js/3.0.7/pixi.js
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js
https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.1.2/tinycolor.min.js
https://gitcdn.xyz/repo/cool-Blue/d3-lib/master/filters/shadow.js