private void Draw() { graphics.Clear(Color.Black); quadtree = new Quadtree(new Rectangle(winWidth / 2, winHeight / 2, winHeight / 2, winWidth / 2), 4, graphics); foreach (var particle in particles) { quadtree.InsertParticle(particle); graphics.FillRectangle(Brushes.White, particle.position.X, particle.position.Y, 2f, 2f); } quadtree.Draw(); pictureBox1.Refresh(); }
private void Subdivide() { int x = boundary.x; int y = boundary.y; int w = boundary.width; int h = boundary.height; Rectangle nw = new Rectangle(x - w / 2, y - h / 2, h / 2, w / 2); Rectangle ne = new Rectangle(x + w / 2, y - h / 2, h / 2, w / 2); Rectangle sw = new Rectangle(x - w / 2, y + h / 2, h / 2, w / 2); Rectangle se = new Rectangle(x + w / 2, y + h / 2, h / 2, w / 2); QTnw = new Quadtree(nw, 4, graphics); QTne = new Quadtree(ne, 4, graphics); QTsw = new Quadtree(sw, 4, graphics); QTse = new Quadtree(se, 4, graphics); }