Mutual Attraction
Nature of Code Lesson #2.6
Finishing off Chapter 2 on forces, let’s look at an “N-Body Simulation” where all movers experience gravitational attraction with all other movers!
Topics
- 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
Community Contributions
It seems like there haven't been made any variations based on this lesson by the community yet. Be the first and add your own! If you don't know how, take a look at this guide.
Links discussed in this lesson
Videos discussed in this lesson
- 2.5 Gravitational Attraction - The Nature of Code by The Coding Train
- 2.1 Simulating Forces: Gravity and Wind - The Nature of Code by The Coding Train
- 5.1 Autonomous Steering Agents - The Nature of Code by The Coding Train
- 3.1 Angles and Rotation - The Nature of Code by The Coding Train
- Coding Challenge #98.1 - Quadtree by The Coding Train