Visual Computing/Hair Strand Simulation
6 / 67

01/2022Visual Computing

Hair Strand Simulation

A hair strand animated in C++/OpenGL as a mass-spring chain, held in shape by structural and bending constraints.

╌╌╌╌

A single hair strand animated as a mass-spring system in C++, drawn with OpenGL. The strand is discretized into a chain of point masses, and springs between them supply the forces that move it.

Three point masses (circles) linked by springs. Each spring pulls its endpoints back toward the rest length; the arrow under the middle mass marks the restoring force a stretch produces.
A strand of eight masses hangs from a single anchor, joined by structural springs between neighbors and dashed bending springs across every other pair; springs tint orange as they strain. The select is the experiment: semi-implicit Euler swings and settles however hard you perturb the strand, while explicit Euler pumps energy into every oscillation until the strand flies out of frame and the sim resets itself.
Mass-spring strand
hanging at equilibrium — perturb it and compare integrators

Adjacent masses are linked by springs that resist stretching. Each exerts a Hooke's-law force pulling the pair back toward the rest length , plus a damping term along the same direction that bleeds off oscillation:

The first bracketed term is the spring: its magnitude grows with how far the current separation has strayed from , and its sign restores toward rest — stretched springs pull in, compressed springs push out. The second term damps only the component of relative velocity along the spring, projected out by the dot product with , so it removes energy from stretching oscillation without fighting the strand's overall motion. The pair force is applied equal and opposite to the two masses, so momentum is conserved.

Structural springs alone would let the strand fold flat, so a second set of stiffer springs spans every other mass, resisting curvature so the strand keeps a smooth bend and springs back toward straight when disturbed.

Summing forces on each mass gives its acceleration, and the state advances by semi-implicit (symplectic) Euler, which updates velocity first and then position from the updated velocity:

The order matters because explicit Euler updates position from the old velocity. On a spring, where the force always opposes displacement, each such step lags the true trajectory and adds a little energy, and over many steps that error compounds: the oscillation grows instead of decaying, and the strand shakes itself apart. Semi-implicit Euler steps the velocity first, then advances position with the new velocity, which folds a half-step of implicitness into the position update and keeps the per-step energy bounded rather than growing. Stability still has a limit set by the stiffest spring: the step must satisfy roughly , so raising to make the strand firmer forces a smaller . The bending springs are the stiffest in the model and set that ceiling, which is the practical reason a mass-spring strand is delicate to tune.

The stability limit and the tangent-following error are properties of the numerical ODE integration, not of the hair model.

References

  1. Project repository
  2. Reference notes: Euler, Improved Euler, and Runge–Kutta

╌╌ END ╌╌