🧶 Rope & Chain Physics
Interactive rope and chain simulation using Verlet integration and Jakobsen distance-constraint relaxation. Drag, pin, and whip a flexible chain in real time.
About this simulation
This simulator builds a rope, chain, bridge, pendulum, or cloth strip out of point particles connected by distance constraints, using Störmer–Verlet integration in its position-based form: each particle stores only its current and previous position, so velocity is implicit (v ≈ x − xPrev) and is never computed directly. Every frame, gravity and a damping factor displace each unpinned particle, then a Jakobsen relaxation pass runs K times, nudging every connected pair back toward its rest length by half the fractional length error along their separation. Pinned particles stay fixed, and an optional circular peg is enforced the same way, by clamping any particle caught inside its radius back onto the circle's edge.
What it shows
A chain of particles rendered as blue stick segments linking small circles; pinned anchors are drawn orange, free particles light grey. The Stats panel reports the rope's rest length, its actual (relaxed) length, the percentage stretch between them, and the fastest-moving particle — a live readout of how close the constraint solver is to converging.
How to use it
Pick a scenario (whip, bridge, free fall, pendulum, or cloth strip), then drag the Segments, Iterations, Gravity, Damping, and Stiffness sliders to change how the rope behaves. Drag any node directly with the mouse or a finger, tick “Show circular peg” to add a draggable obstacle, and use Pause / Reset to freeze or rebuild the scene.
Did you know?
A rope or chain hanging freely under gravity settles into a catenary curve, not a parabola — the two look similar but are mathematically distinct. Architect Antoni Gaudí exploited this by building upside-down hanging-chain models of the Sagrada Família, letting gravity work out the compression-only arch shapes for him. The same particle-and-constraint trick used here, position-based dynamics, also drives cloth, hair, and ragdoll physics in most modern game engines.
Frequently Asked Questions
What algorithm does this rope simulation use?
It uses Verlet integration combined with Jakobsen constraint relaxation, a technique known as position-based dynamics (PBD). Each particle only stores its position and previous position; gravity and damping displace particles directly each frame, then a separate relaxation pass repeatedly nudges connected particles back toward their rest distance. This avoids solving stiff differential equations directly and is the same method used for cloth, hair, and rope in many real-time games.
Why doesn't the simulation store velocity as its own variable?
This is the Störmer–Verlet form of integration: velocity is implicit, recovered as v ≈ x − xPrev rather than tracked as a separate quantity. It is numerically stable and, crucially, makes constraint solving simple, since the Jakobsen relaxation pass only has to move particle positions directly; the implied velocity for the next frame updates automatically from the new position and the position it just came from.
What does the Iterations (K) slider actually control, and why does raising it make the rope stiffer?
Each iteration is one pass over every stick constraint in the rope, and a single pass only partially corrects each link's length error. With few iterations the rope behaves like a soft elastic band that visibly stretches under load; with many iterations the repeated corrections converge closer to an inextensible rope, where every segment sits almost exactly at its rest length.
Why does the rope stretch and show a nonzero Stretch percentage in the stats panel?
Jakobsen relaxation is an approximate iterative solver, not an exact one. With a finite number of iterations K and simultaneous pulls from gravity, neighbouring constraints, pinned points, and the peg, the rope rarely reaches a perfectly zero-error state within one frame. Raising K reduces stretch at the cost of more computation per frame, while lowering gravity, damping, or the peg's push has a similar effect.
How does the draggable peg interact with the rope, and is it real collision physics?
The peg does not use full rigid-body collision. After each constraint iteration the simulation checks whether an unpinned particle now lies inside the peg's circle and, if so, projects it directly back onto the circle's edge. Repeating this alongside the stick constraints, K times per frame, makes the rope appear to wrap and slide around the peg convincingly, even though it is just a positional clamp rather than a physical response with impulses or friction.
A rope as point particles linked by distance constraints, integrated with Verlet and Jakobsen relaxation. Drag any node, pin ends, wrap the rope around a peg, build a cloth strip.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install