Spring Forces
Coding Challenge #160
Boing! Time to simulate a spring force! This challenge fits into chapters 2 and 3 of the Nature of Code and demonstrates how to simulate the oscillating motion of a spring using vectors and forces.
Topics
- 0:00 - Choo choo!! Springs Coding Challenge!
- 0:40 - Explain! What is Hooke's Law?
- 2:51 - Code! Let's make a 1 dimensional spring!
- 5:13 - Explain! How can we bring in vectors?
- 7:17 - Code! Let's adjust the code to use vectors.
- 11:57 - Code! Let's add gravity!
- 13:03 - Code! How can we control the spring with our mouse?
- 13:53 - Explain! But wait!! Particles!
- 15:14 - Copy & Paste! A particle class.
- 16:41 - Code! Let's make bob and anchor particles.
- 18:01 - Code! We need a spring class.
- 21:32 - Debug! What is missing?
- 23:16 - It works!
- 24:16 - Code! But wait!! Particle system!
- 25:28 - Code! Let's connect the particles with springs.
- 27:12 - Code! We can refine it a bit.
- 29:29 - Code! Playing with beginShape() and endShape().
- 31:07 - Ideas! If you make a swishy robot share it with me!
Community Contributions
- Grab Any Spring Particle by Galitan (Source Code)
- Spring Force Contribution - Grass by Leonardo Lewandowski (Source Code)
- Mistake are beautiful by Joseph Gabriel (Source Code)
- Simplified Wilberforce Pendulum by Yile Xu (Source Code)
- Spring Forces Playground by HoangTran (Source Code)
- Spring System by Nick Wilcox (Source Code)
- Springy pendulum by Ángel Carvajal Ruiz (Source Code)
- Bunch Of Jelly THings by Harsha Addanki (Source Code)
- Cloth Simulation by CodeFish (Source Code)
You can also add your own version! (See how)
Links discussed in this coding challenge
Videos discussed in this coding challenge
- Texturing Cloth Simulation - Coding Challenge #63 by The Coding Train
- Simple Particle System - Coding Challenge #78 by The Coding Train