-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathquadtree.js
More file actions
33 lines (25 loc) · 812 Bytes
/
quadtree.js
File metadata and controls
33 lines (25 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var Quadtree = function(x, y){
if(typeof x !== 'number' || typeof y !== 'number'){
throw new Error('You must supply coordinate to the initial node!');
}
this.coordinates = [x, y];
this.children = {
topRight: null,
topLeft: null,
bottomLeft: null,
bottomRight: null
}
}
Quadtree.prototype.add = function(x, y){
/* Adds a new node to the tree with the given coordinates */
}
Quadtree.prototype.find = function(x, y){
/* Returns either the node with the given coordinates or null */
}
Quadtree.prototype.findInRange = function(topRight, topLeft, bottomLeft, bottomRight){
/* Returns a list of nodes with coordinates within the input rectangle */
}
/* ---EXTRA CREDIT--- */
Quadtree.prototype.remove = function(x, y){
/* Removes the node with the given coordinates */
}