Skip to main content
100%

Force-Directed Lattice

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Jul 28, 2020
Created on Jul 28, 2020

A force-directed lattice uses a 20x20 grid of nodes connected by links, simulated with `d3.forceSimulation` and a `d3.forceLink` whose link constraint is applied ten times per step (`iterations(10)`), strengthening the lattice’s rigidity. The code renders nodes as small circles and links as lines on a Canvas 2D context, with `d3.drag` enabling interactive node repositioning via fixed positions (`fx`, `fy`). The visible effect shows the lattice folding and warping under the charge force while maintaining its mesh-like structure.

AI-generated description

This demonstrates forceLink.iterations, which strengthens d3-force’s link constraint by applying the constraint multiple times per simulation step.

gpl-3.0 Licensed

Similar vizzes