Main content

### Course: Pixar in a Box > Unit 4

Lesson 2: Code your own simulation- Starting with particles
- Step 1 (particle under gravity)
- 1D spring-mass system
- Step 2 (spring-mass system)
- Damping
- Step 3 (damped spring-mass system)
- 2D spring-mass system
- Step 4 (2D spring-mass system)
- Multiple spring-mass system
- Step 5 (multiple spring-mass system)

© 2024 Khan AcademyTerms of usePrivacy PolicyCookie Notice

# Damping

Spring simulations can create bouncy hair, but adding dampers makes it more realistic. Dampers resist velocity changes, with force depending on damping coefficient and spring displacement velocity. Balancing spring stiffness and damping achieves lifelike motion. Experiment with damping and spring force coefficients in the JavaScript program for realistic behavior.

## Want to join the conversation?

- Is this lesson ok for 4th grade?(7 votes)
- I started doing on the first day of 5th grade, and I wasn't super confused, so I'd say yes, it's probably fine, and they have the grade suggestions, the first half is usually for 5th-8th grade, and the second half is for high school, so stick with the first half if you're really worried about it.(15 votes)

- I not in the mood for making a 3D video yet. But will I ever make a romantic video about Chuck Chicken?(8 votes)
- Depends. If you enjoy Chuck Chicken and you have the time, maybe. Few will watch it due to his slight obscurity, however.(5 votes)

- Why is over damping not relistic(3 votes)
- Overdamping results in a situation where the "spring" appears as if it were coated with molasses, which is not our desired effect.(6 votes)

- hi, the video is no longer available, can you re-upload it please(4 votes)
- Yeah I cant watch it either(3 votes)

- At0:36In the video What force is she talking about? Is it the spring force or the damping force(4 votes)
- I don't get this, i don't understand the coding?(3 votes)
- hey this video dosent work for me(3 votes)
- why is the video unavailable?(3 votes)
- whomst calls a up down coil boy a spring?(2 votes)
- Why is this video not available?(2 votes)

## 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.