Skip to content
Constraints (Joints)
step 1/5

Reading — step 1 of 5

Read

~2 min readCollision Response

Constraints (Joints)

Joints connect bodies with fixed relationships:

  • Revolute (hinge): two bodies share an anchor; can rotate freely.
  • Prismatic (slider): bodies translate along an axis.
  • Distance (rope, spring): two anchors maintain distance (or spring force).
  • Weld: rigid connection.
  • Pulley, gear: complex coupled motion.

Solving constraints: keep bodies satisfying the constraint each step.

Iterative solver (sequential impulses, Gauss-Seidel style):

  1. For each constraint, compute impulse to satisfy.
  2. Apply to bodies.
  3. Repeat for several iterations (8-15 typical).
  4. Constraints settle.
python

Spring constraint (Hooke's law):

python

Damping: f = -c * relative_velocity. Prevents oscillation.

Rope:

  • Distance constraint with max_length.
  • Constraint only when stretched (slack rope = inactive).

Chains:

  • Sequence of bodies + joints.
  • Solver iterates from one end to other.
  • Many iterations needed for long chains.

Cloth simulation:

  • Grid of bodies + structural + shear + bending springs.
  • Verlet integration + position-based dynamics.

Game examples:

  • Vehicle: 4 wheels + body + 4 distance constraints (springs for suspension).
  • Ragdoll: bones + revolute joints (limbs, spine).
  • Door: revolute joint with motor + limit.

For our toy: distance + spring constraints. Skip rotation for simplicity.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…

Constraints (Joints) — Build a 2D Physics Engine