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. https://thecodingtrain.com/challenges/160-spring-forces
p5.js Web Editor Sketches:
🕹️ Simple Spring: https://editor.p5js.org/codingtrain/sketches/dcd6-2mWa
🕹️ Spring Vector: https://editor.p5js.org/codingtrain/sketches/_A2pm_SSg
🕹️ Spring OOP: https://editor.p5js.org/codingtrain/sketches/9BAoEn4Po
🕹️ Soft Spring: https://editor.p5js.org/codingtrain/sketches/S5dY7qjxP
🎥 Previous Coding Challenge: https://youtu.be/NBWMtlbbOag?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🎥 All Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🎥 Previous Nature of Code Video: https://www.youtube.com/watch?v=NBWMtlbbOag&list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
🎥 Next Nature of Code Video: https://www.youtube.com/watch?v=syR0klfncCk&list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
🎥 All Nature of Code Videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
Links discussed in this video:
🔗 Nature of Code 3.10 Spring Forces: https://natureofcode.com/book/chapter-3-oscillation/index.html#310-spring-forces
🔗 Nature of Code Playlist: https://thecodingtrain.com/learning/nature-of-code/index
🔗 toxiclibs.js: http://www.haptic-data.com/toxiclibsjs/
🔗 curveVertex() (p5.js Reference): https://p5js.org/reference/#/p5/curveVertex
Other videos mentioned in this video:
🎥 Texturing Cloth Simulation - Coding Challenge #63: https://youtu.be/JunJzIe0hEo
🎥 Simple Particle System - Coding Challenge #78: https://youtu.be/UcdigVaIYAk
Timestamps:
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!
🚂 Website: http://thecodingtrain.com/
👾 Share Your Creation! https://thecodingtrain.com/Guides/community-contribution-guide.html
🚩 Suggest Topics: https://github.com/CodingTrain/Rainbow-Topics
💡 GitHub: https://github.com/CodingTrain
💬 Discord: https://discord.gg/hPuGy2g
💖 Membership: http://youtube.com/thecodingtrain/join
🛒 Store: https://standard.tv/codingtrain
📚 Books: https://www.amazon.com/shop/thecodingtrain
🖋️ Twitter: https://twitter.com/thecodingtrain
📸 Instagram: https://www.instagram.com/the.coding.train/
🎥 Coding Challenges: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
🎥 Intro to Programming: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
🔗 p5.js: https://p5js.org
🔗 p5.js Web Editor: https://editor.p5js.org/
🔗 Processing: https://processing.org
📄 Code of Conduct: https://github.com/CodingTrain/Code-of-Conduct