Springs

Hooke's Law
Force is proportional to displacement

K = spring constant
d = displacement from rest length

Spring is modeled as 2 point masses, linked by the spring

Equal but opposite force is applied to each end






Springs


When spring is stretched, spring force pulls masses together


When spring is compressed, spring force pushes masses apart






Springs

Vector between the points is used to compute displacement and the direction of force:

    v = point1 - point0
    displacement = v.length() - restLength
    v.normalize()
    force = springConstant * displacement * v





Springs






Spring Classes

Two classes needed: PointMass and Spring

PointMass

Attributes:
Mass
Position
Velocity
Acceleration
Functions:
Clear forces
Add force
Update
Freeze





Spring Classes

Spring

Attributes:
Two PointMasses
Spring constant
Rest length
Functions:
Update





Spring-based Objects

Solid objects can be simulated as a collection of springs

Stiff springs (large spring constant) produce rigid objects.
Loose springs produce jello-like objects.






Spring-based Objects

Often, additional internal springs are needed to keep a shape from collapsing






Cloth

Cloth can be simulated by a mesh of springs






Cloth

Diagonal springs are again useful, to keep the mesh from collapsing easily






Numerical Explosion

Spring calculations are prone to "numerical explosion"

Possible solutions:
  • Smaller timesteps
  • Looser springs
  • Arbitrarily limit velocities
  • Better integration method


Creative Commons License
This document is by Dave Pape, and is released under a Creative Commons License.