Uploaded March 2022 | Updated November 2026, 20 hours ago
Finishing off Chapter 2 on forces, let's look at an "N-Body Simulation" where all movers experience gravitational attraction with all other movers! thecodingtrain.com/tracks/the-nature-of-code-2/noc/2-forces/6-mutual-attraction
p5.js Web Editor Sketches:
πΉοΈ Mutual Attraction (N-Body): editor.p5js.org/codingtrain/sketches/bEt7eLZ6Y
πΉοΈ Mutual Attraction (N-Body) with Barnes Hut: editor.p5js.org/codingtrain/sketches/joXNoi9WL
π₯ Previous video: youtu.be/EpgB3cNhKPM?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ Next video: youtu.be/DMg-WRfNB60?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ All videos: youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
Links discussed in this video:
π Newton's law of universal gravitation (Wikipedia): en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation
π Nature of Code Book - 2.10 Everything Attracts (or Repels) Everything: natureofcode.com/book/chapter-2-forces/#210-everything-attracts-or-repels-everything
π p5.Vector rotate(): p5js.org/reference/#/p5.Vector/rotate
π N-Body Choreographies research paper by Montaldi and Steckles: personalpages.manchester.ac.uk/staff/j.montaldi/Choreographies/about.html
π N-Body Choreographies animation tool by Dan Gries: personalpages.manchester.ac.uk/staff/j.montaldi/Choreographies
Other videos mentioned in this video:
π₯ 2.5 Gravitational Attraction - The Nature of Code: youtu.be/EpgB3cNhKPM
π₯ 2.1 Simulating Forces: Gravity and Wind - The Nature of Code: youtu.be/Uibl0UE4VH8
π₯ 5.1 Autonomous Steering Agents - The Nature of Code: youtu.be/P_xJMH8VvAE
π₯ 3.1 Angles and Rotation - The Nature of Code: youtu.be/DMg-WRfNB60
π₯ Coding Challenge #98.1 - Quadtree: 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: thecodingtrain.com
πΎ Share Your Creation! thecodingtrain.com/Guides/community-contribution-guide.html
π© Suggest Topics: github.com/CodingTrain/Rainbow-Topics
π‘ GitHub: github.com/CodingTrain
π¬ Discord: discord.gg/hPuGy2g
βͺ Nebula: go.nebula.tv/codingtrain
π Membership: youtube.com/thecodingtrain/join
π Store: standard.tv/codingtrain
π Books: amazon.com/shop/thecodingtrain
ποΈ Twitter: twitter.com/thecodingtrain
πΈ Instagram: instagram.com/the.coding.train
π₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: p5js.org
π p5.js Web Editor: editor.p5js.org
π Processing: processing.org
π Code of Conduct: github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/website/issues/new
Finishing off Chapter 2 on forces, let's look at an "N-Body Simulation" where all movers experience gravitational attraction with all other movers! thecodingtrain.com/tracks/the-nature-of-code-2/noc/2-forces/6-mutual-attraction
p5.js Web Editor Sketches:
πΉοΈ Mutual Attraction (N-Body): editor.p5js.org/codingtrain/sketches/bEt7eLZ6Y
πΉοΈ Mutual Attraction (N-Body) with Barnes Hut: editor.p5js.org/codingtrain/sketches/joXNoi9WL
π₯ Previous video: youtu.be/EpgB3cNhKPM?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ Next video: youtu.be/DMg-WRfNB60?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
π₯ All videos: youtube.com/playlist?list=PLRqwX-V7Uu6ZV4yEcW3uDwOgGXKUUsPOM
Links discussed in this video:
π Newton's law of universal gravitation (Wikipedia): en.wikipedia.org/wiki/Newton's_law_of_universal_gravitation
π Nature of Code Book - 2.10 Everything Attracts (or Repels) Everything: natureofcode.com/book/chapter-2-forces/#210-everything-attracts-or-repels-everything
π p5.Vector rotate(): p5js.org/reference/#/p5.Vector/rotate
π N-Body Choreographies research paper by Montaldi and Steckles: personalpages.manchester.ac.uk/staff/j.montaldi/Choreographies/about.html
π N-Body Choreographies animation tool by Dan Gries: personalpages.manchester.ac.uk/staff/j.montaldi/Choreographies
Other videos mentioned in this video:
π₯ 2.5 Gravitational Attraction - The Nature of Code: youtu.be/EpgB3cNhKPM
π₯ 2.1 Simulating Forces: Gravity and Wind - The Nature of Code: youtu.be/Uibl0UE4VH8
π₯ 5.1 Autonomous Steering Agents - The Nature of Code: youtu.be/P_xJMH8VvAE
π₯ 3.1 Angles and Rotation - The Nature of Code: youtu.be/DMg-WRfNB60
π₯ Coding Challenge #98.1 - Quadtree: 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: thecodingtrain.com
πΎ Share Your Creation! thecodingtrain.com/Guides/community-contribution-guide.html
π© Suggest Topics: github.com/CodingTrain/Rainbow-Topics
π‘ GitHub: github.com/CodingTrain
π¬ Discord: discord.gg/hPuGy2g
βͺ Nebula: go.nebula.tv/codingtrain
π Membership: youtube.com/thecodingtrain/join
π Store: standard.tv/codingtrain
π Books: amazon.com/shop/thecodingtrain
ποΈ Twitter: twitter.com/thecodingtrain
πΈ Instagram: instagram.com/the.coding.train
π₯ Coding Challenges: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
π₯ Intro to Programming: youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA
π p5.js: p5js.org
π p5.js Web Editor: editor.p5js.org
π Processing: processing.org
π Code of Conduct: github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/website/issues/new










