2.6 Mutual Attraction - The Nature of Code
Finishing off Chapter 2 on forces, let's look at an "N-Body Simulation" where all movers experience gravitational attraction with all other movers! https://thecodingtrain.com/tracks/the-nature-of-code-2/noc/2-forces/6-mutual-attraction
p5.js Web Editor Sketches:
πΉοΈ Mutual Attraction (N-Body): https://editor.p5js.org/codingtrain/sketches/bEt7eLZ6Y
πΉοΈ Mutual Attraction (N-Body) with Barnes Hut: https://editor.p5js.org/codingtrain/sketches/joXNoi9WL
π₯ Previous video: https://youtu.be/EpgB3cNhKPM?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ Next video: https://youtu.be/DMg-WRfNB60?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ All videos: https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
Links discussed in this video:
π Newton's law of universal gravitation (Wikipedia): https://en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation
π Nature of Code Book - 2.10 Everything Attracts (or Repels) Everything: https://natureofcode.com/book/chapter-2-forces/#210-everything-attracts-or-repels-everything
π p5.Vector rotate(): https://p5js.org/reference/#/p5.Vector/rotate
π N-Body Choreographies research paper by Montaldi and Steckles: https://personalpages.manchester.ac.uk/staff/j.montaldi/Choreographies/about.html
π N-Body Choreographies animation tool by Dan Gries: https://personalpages.manchester.ac.uk/staff/j.montaldi/Choreographies/
Other videos mentioned in this video:
π₯ 2.5 Gravitational Attraction - The Nature of Code: https://youtu.be/EpgB3cNhKPM
π₯ 2.1 Simulating Forces: Gravity and Wind - The Nature of Code: https://youtu.be/Uibl0UE4VH8
π₯ 5.1 Autonomous Steering Agents - The Nature of Code: https://youtu.be/P_xJMH8VvAE
π₯ 3.1 Angles and Rotation - The Nature of Code: https://youtu.be/DMg-WRfNB60
π₯ Coding Challenge #98.1 - Quadtree: https://youtu.be/OJxEcs0w_kE
Timestamps:
0:00 Introducing Today's Topic
0:30 Recap Single attractor system
1:20 The two body problem
2:21 Euler Integration
2:53 Other integration options
4:00 Coding 2-body simulation
7:56 The three body problem
8:15 Coding 3-body simulation
9:04 Refactoring for n-body
10:48 Adding a fourth mover
11:38 Looking at initial states
12:03 Shape 1: donut
13:33 The p5 Vector rotate() function
16:12 Trying out different variations
17:34 Looking at efficiency
19:10 Adding the sun
20:46 Looking at other examples
21:21 Exercise for viewers
22:09 Invite to chapter 3 and goodbye
π 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
βͺ Nebula: https://go.nebula.tv/codingtrain
π 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
This description was auto-generated. If you see a problem, please open an issue: https://github.com/CodingTrain/website/issues/new