Skip to content

Commit

Permalink
Update instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
leonmavr committed Sep 27, 2024
1 parent c80f2dd commit b007893
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ project, a **point quadtree** is implemented.
The idea is that each node represents a rectangel in 2D space. The rectangle can
store a limited number of points. If its capacity is reached, a node gets
divided into 4 NW, NE, SE, SW children (leaves), where its points get
re-distributed. Some nice theoretical resources are found in [1], [2].
re-distributed. Some nice theoretical resources are found in [1], [2], [3].

To get some intuition, the schematic below shows what happens to a node of
capacity of 2 when 3 points are sequentially inserted.
```
spatial representation:
capacity=2 NW NE
+--------------------+ +--------------------+ +--------------------+
| | | | | | |
Expand All @@ -29,46 +30,67 @@ capacity=2 NW NE
| | | | | | |
+--------------------+ +--------------------+ +--------------------+
SW SE
tree representation:
+--+ +--+ +--+
|* | |**| | |
+--+ +--+ +--+
|
|
+------+---+---+------+
| | | |
+--+ +--+ +--+ +--+
|* | | | |* | |* |
NW +--+ NE+--+ SE+--+ SW+--+
```

# 2. Usage

## 2.1 Project structure
```
.
├── examples
│   ── 01_particle_sim.c <- demo
├── examples <- directory where demos can be added
│   ── 01_particle_sim.c <- demo
├── include
│   ├── quad.h <- library
│   └── viz.h <- GNUplot visualizer
│   ├── quad.h <- library
│   ├── viz_gplot.h <- gnuplot plotter
│   ├── viz.h <- plotter interface
│   └── viz_ppm.h <- ppm frame plotter
├── src
│   ├── quad.c <- library
│   └── viz.c <- GNUplot visualizer
│   ├── viz_gplot.c <- gnuplot plotter
│   └── viz_ppm.c <- ppm frame plotter
└── test
├── nanotest.h <- testing framework
└── test.c <- unit tests
├── nanotest.h <- unit test framework
└── tests.c <- unit tests
```
The visualizer plots the quadtree in real time via a pipe fed to GNUplot. The
library is independent from the visualizer.
The visualizer plots the quadtree in real time either via a pipe fed to GNUplot
or directly as .ppm frames. The quadtree library is independent from the
visualizer.

## 2.2. Dependencies and required tools

* `make` to compile the project.
* `gnuplot` to run the particle simulation demo.
* `gcc` is the default compiler, set in the Makefile.
* either `gnuplot` or media player like `mpv` to run the particle simulation
demo.

## 2.3. Compilation

To compile the library with any demo(s):
```
make
```
You can compile the example(s) with either GNUplot or .ppm frame emitter as the
visualizer.

| gnuplot | ppm frames |
| -------- | ---------------- |
| `make` | `make -DUSE_PPM` |

Then all demos under `examples` will be compiled against the library. All
executables will be generated in the root. A particle simulation to demonstrate
how the tree works has been written. To run it:
```
./01_particle_sim | mpv -
```

| gnuplot | ppm frames |
| --------------------- | ----------------------------------------------------- |
| `./01_particle_sim` | `./01_particle_sim | mpv --no-correct-pts --fps=30 -` |

To compile and run the unit tests:
```
make test
Expand Down

0 comments on commit b007893

Please sign in to comment.