Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eskaliert680/edamame
An N-body simulation library written in C++ with Barnes-Hut trees.
https://github.com/eskaliert680/edamame
barnes-hut gravity nbody-simulation physics-simulation
Last synced: 6 days ago
JSON representation
An N-body simulation library written in C++ with Barnes-Hut trees.
- Host: GitHub
- URL: https://github.com/eskaliert680/edamame
- Owner: eskaliert680
- Created: 2024-11-10T17:46:36.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-11-14T20:34:58.000Z (about 2 months ago)
- Last Synced: 2024-12-19T15:11:17.363Z (19 days ago)
- Topics: barnes-hut, gravity, nbody-simulation, physics-simulation
- Language: C++
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Edamame
An N-body simulation library written in C++ with Barnes-Hut trees.
## Installation
Clone the repo:```bash
git clone https://github.com/letlovewin/edamame.git
```
Then just put the `gravity.h` file into your program and then compile it however you do.## Usage
Everything in this library relies on the `Vector2` class. To initialize a new `Vector2`, write:
```cpp
Vector2 vec(x1,x2);
```where `x1` and `x2` are `float`.
To establish new particles in your simulation, write:
```cpp
Particle p(position,velocity,mass);
```where `position` and `velocity` are `Vector2` and `mass` is a `float`.
Next, to set up your simulation, you create a `Universe` object:
```cpp
Universe universe(begin_time,end_time,step_size,radius);
```Where `begin_time`, `end_time`, `step_size`, and `radius` are `float`. `radius` is the size of your universe. If any particles go past the bounds of this radius (specifically it is a square with side lengths equal to `radius`, and its bottom left corner is at (0,0)) they will be excluded from the computation of net forces of particles.
To add your particles to the `Universe` object, you write:
```cpp
universe.addChild(p);
```and to start the simulation,
```cpp
universe.start();
```