If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

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

Video transcript

now that we have a spring simulator let's address a problem we face in the first lesson previously we tried only using Springs to model our strands of hair that resulted in the hair which was really bouncy funny 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 force 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 is no damping force since there's no movement to resist we can use a really simple equation to describe the situation damping force equals damping coefficient times velocity of the particle 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 call this a 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 sense it bounces forever let's try increasing our damping variable to 1 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 dam 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