Skip to main content
100%

Collision Detection in a tight square

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Aug 7, 2016
Created on Aug 7, 2016

A thousand colored circles of varying radii bounce and slide within a square boundary, colliding and repelling to avoid overlap. The simulation uses d3.forceSimulation with a custom force function that pushes nodes away from the square’s edges, while d3.forceCollide handles circle-to-circle collisions. The Canvas API renders each circle with a distinct fill from the d3.schemeCategory10 palette, and the white strokes emphasize boundaries during the continuous tick updates.

AI-generated description

This example uses d3.forceCollide to prevent circles from overlapping.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/31ce330646fa8bcb7289ff3b97aab3f5'>Collision Detection</a>

See also Bounded Force Layout - very tightly packed.

gpl-3.0 Licensed

Similar vizzes