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):
- For each constraint, compute impulse to satisfy.
- Apply to bodies.
- Repeat for several iterations (8-15 typical).
- 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…