An open API service indexing awesome lists of open source software.

https://github.com/hanzopgp/particleattraction

Simple particle attraction representation using Newton's law of universal gravitation and P5 library.
https://github.com/hanzopgp/particleattraction

p5js personal web

Last synced: 12 months ago
JSON representation

Simple particle attraction representation using Newton's law of universal gravitation and P5 library.

Awesome Lists containing this project

README

          

# ParticleAttraction

## Table of contents :

1. [Presentation](#presentation-)
3. [How to use](#how-to-use-)
2. [How does it work](#how-does-it-work-)
4. [Links](#links-)

## Presentation :

>This graphical simulation is using the Newton's law of universal gravitation. This is my first project using P5 library, this library is really enjoyable to use. You can see the demo :

>- [With thin lines](https://hanzopgp.github.io/ParticleAttraction/?mode=1).
>- [With thick lines](https://hanzopgp.github.io/ParticleAttraction/?mode=2).
>- [With points](https://hanzopgp.github.io/ParticleAttraction/?mode=3).
>- [With lines disappearing](https://hanzopgp.github.io/ParticleAttraction/?mode=4).
>- [For slow computers](https://hanzopgp.github.io/ParticleAttraction/?mode=5).

>I learnt p5 thanks to [Daniel Shiffman](https://shiffman.net/).

## How to use :

- Clone the repository
- Just put the index.html file in your browser.
- If you don't put any parameters you get the mode 3.
- If you want to test other mode juste add ?mode=1 for example at the end of the url.
- Simulation starts at 300 frames.
- Use "B" and click to place a repulsor.
- Use "V" and click to place an attractor.
- Use "P" to pause.

## How does it work :

All the particles on the screen are attracted or repulsed by the green and red static elements. Their speed is calculated depending their gravitation force, thanks to the universal gravitation equation. There is basic physics implemented using p5 functions.

## Links :

- https://p5js.org/
- https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
- https://shiffman.net/