- The simulations in the previous section, especially the one with the domino pieces, looked a bit unrealistic, because I did not simulate
*friction*. Actually, the simulations make much more sense if you image the domino pieces and ground planes to be of very slippery ice. Here, I will briefly show how to add friction -*briefly*, because it is a straightforward extension of the collision constraint method. Friction could be implemented in a variety of other ways, most notably friction forces, but the impulse-based notation is very easy and gives convincing results. - The figure on the right illustrates the relation between friction and collision constraints - both act on every contact point, but with different direction and magnitude. The collision constraint impulse applied to body A, is a multiple of the surface normal , while the friction impulse is a multiple of the surface
*tangent*. - In terms of constraint equations, friction can be seen as a velocity equality constraint aiming for a
*tangent velocity*of 0, i.e. . This is just the equation we had in the previous Collision Constraint section, with replaced by . So we can reuse the formula derived for the Jacobian and just replace with :

- The bias term can be set to 0, and the update step again consists of , with
- Computing the magnitude of the friction impulse, , will give a value that stops the body from moving, no matter how light it is and how big the surface friction actually is. Under more realistic circumstances - Coulomb friction - the friction force magnitude is a fraction of the normal force magnitude, , or equivalently (due to ) in the impulse domain, . In other words, we compute the friction impulse magnitude , but clamp it such that .
- The actual implementation, once collision constraint impulse have been computed, is straightforward. In each time step of the iteration, and within each contact that is processed, one first computes the normal (collision resolving) impulse and updates the bodies' velocities. Then (before proceeding to the next contact), one takes the updated velocities and the Jacobian of the friction constraint, computes the respective , clamps it to the bounds above, and applies the tangent impulse the velocity.
- Below, I added the same three simulations I used in the collision constraint section, with < 20 lines of code added to simulate friction. You can change the friction to 0 to get the same behavior as in the previous simulations.

mass: | |

x0: | |

y0: | |

theta0: | |

vx0: | |

vy0: | |

vAng0: | |

friction: | |

tStop: |

t=0s

domino spacing: | |

vAng0: | |

friction: | |

tStop: |

t=0s

friction: | |

tStop: |

t=0s