xxxxxxxxxx
47
const SIZE = 6;
const NUM_POINTS = 12;
var points = [];
var tree = null;
function setup() {
createCanvas(400, 400);
for (let i = 0; i < NUM_POINTS; i++) {
points.push(createVector(random(width), random(height)));
}
tree = new KDTree();
tree.insertPoint(points[0]);
}
function draw() {
background(220);
fill(255, 255, 0);
for (p of points) {
circle(p.x, p.y, SIZE);
}
}
function mousePressed() {
points.push(createVector(mouseX, mouseY));
}
function KDTree() {
this.root = new Node();
this.insertPoint = function(p) {
if (this.root.isLeaf()) {}
}
}
function Node() {
this.l = null;
this.r = null;
this.isLeaf = function() {
return this.l == null && this.r == null;
}
}