1
- A QuadTree example for JavaScript with [ p5.js] ( http://p5js.org ) .
1
+ A QuadTree example (and almost sort of a JavaScript library) with [ p5.js] ( http://p5js.org ) .
2
2
3
- # QuadTree
3
+ ## QuadTree
4
4
* [ QuadTree on wikipedia] ( https://en.wikipedia.org/wiki/Quadtree )
5
5
* [ QuadTree pseudo-code] ( https://en.wikipedia.org/wiki/Quadtree#Pseudo_code )
6
6
* [ QuadTree video tutorial part 1] ( https://youtu.be/OJxEcs0w_kE )
7
7
* [ QuadTree video tutorial part 2] ( https://youtu.be/QQx_NmCIuCY )
8
8
9
- # QuadTree Code and Example
10
- * [ QuadTree Repo] ( https://github.com/CodingTrain/QuadTree )
11
- * [ QuadTree code] ( https://github.com/CodingTrain/QuadTree/blob/master/quadtree.js )
12
- * Visualize the QuadTree: [ code] ( https://github.com/CodingTrain/QuadTree/tree/master/examples/visualize_qtree ) , [ demo] ( https://codingtrain.github.io/QuadTree/examples/visualize_qtree/ )
13
- * Collision Detection with QuadTree: [ code] ( https://github.com/CodingTrain/QuadTree/tree/master/examples/intersection_qtree ) , [ demo] ( https://codingtrain.github.io/QuadTree/examples/intersection_qtree/ )
9
+ ## How to use
10
+ * You can download and include ` quadtree.js ` in your p5 sketch or refer to it via this CDN link:
14
11
15
- # Testing
12
+ ``` html
13
+ <script src =" https://cdn.jsdelivr.net/gh/CodingTrain/QuadTree/quadtree.js" ></script >
14
+ ```
15
+
16
+ Once you've include the library you can create a ` QuadTree ` object a ` Rectangle ` boundary and maximum capacity:
17
+
18
+ ``` javascript
19
+ const r = new Rectangle (0 , 0 , width, height);
20
+ const capacity = 4 ;
21
+ const quadtree = new QuadTree (r, capacity);
22
+ ```
23
+
24
+ ## Testing
16
25
To run tests use one of the following commands
17
26
18
27
For continuous testing
@@ -26,10 +35,11 @@ npm run test
26
35
```
27
36
This will output to the ` coverage ` folder where you can few test coverage by opening index.html
28
37
29
- # Other QuadTree libraries in JS
38
+ ## Other QuadTree libraries in JS
30
39
* [ quadtree-js] ( https://github.com/timohausmann/quadtree-js )
31
40
* [ d3-quadtree] ( https://github.com/d3/d3-quadtree )
32
41
33
- # Other Versions
34
- ## Ports to other languages
42
+ ## Other Versions
43
+
44
+ ### Ports to other languages
35
45
* Carla de Beer (Processing port) - [ GitHub] ( https://github.com/Carla-de-Beer/Processing/tree/master/QuadTree )
0 commit comments