Finishing off Chapter 2 on forces, let's look at an "N-Body Simulation" where all movers experience gravitational attraction with all other movers!
Wikipedia entry on the law of universal gravitation
Link to chapter 2.10 - Everything Attracts (or Repels) Everything
Link to p5 Reference entry on the rotate() method
Research paper by Montaldi and Steckles
Dan Gries' tool for animating a range of different N-Body Choreographies
Previous Nature of Code video on gravitational attraction
Nature of Code video on simulating gravity and wind forces
Nature of Code video on creating agents that can move themselves
Nature of Code video covering the basics of angles and rotation in p5.js
Coding Challenge to implement a Quadtree data structure and visualize it in p5.js
- Editing
by Mathieu Blanchette
- Animations
by Jason Heglund