Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

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.

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();
```