Current time:0:00Total duration:2:38

# Damping

## Video transcript

(jumping, bouncing) (light switches on) - Now that we have a spring
simulator, let's address a problem we faced in the first lesson. Previously, we tried only using springs to model our strands of hair. That resulted in a hair
which was really bouncy. Fun, yes, but not very realistic. To address this we added
a damper to each spring. Remember, dampers resist
changes in velocity causing our springs to settle
down much more quickly. Mathematically, a damper is quite simple. We can think of the damper
as a new force which acts in the opposite direction
of the spring force. The size of this source
will depend on two things. First, how strong the damper is, we'll call that the damping coefficient. Second, the velocity of
the spring displacement. If the spring is stretching
or compressing very quickly, the damping force will be
large and if the spring isn't moving, there's no damping force since there's no movement to resist. We can use a really simple equation to describe this situation. Damping force equals
damping coefficient times velocity of the product. Okay, let's add this
new force to our system. At the top of our program
we need to initialize a new variable called damping. Earlier, we called this
the damping coefficient. Zero means no damping
and the higher the number the stronger the damper is. Now we can move into our draw function and define this new damping force. Right below our spring
force calculation I'm going to define a new variable
called damping force Y and it will be equal to
damping times velocity Y. Next we add this force to our
existing force Y calculation. Currently, we are only taking gravity and spring force into consideration. Now we need to subtract
our damping force Y since it resists the spring force. Okay, let's try this out. Here's the response with no damping. We call this system under-damped
since it bounces forever. Let's try increasing our
damping variable to one. Notice it comes to rest more quickly. This is getting better,
but if I set damping to something huge, like
100, we run into a problem. This is called over-damping.
The spring barely moves. This isn't realistic. The trick is to find the right
balance of spring stiffness and damping to get realistic motion. Let's pause here so you can
try this out for yourself. Try experimenting with the
damping and spring force coefficients to get a realistic behavior. Good luck.