Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Problem of Continuously Inserting Large Area Rectangles #21

Open
zs782306174 opened this issue Oct 20, 2023 · 1 comment
Open

The Problem of Continuously Inserting Large Area Rectangles #21

zs782306174 opened this issue Oct 20, 2023 · 1 comment

Comments

@zs782306174
Copy link

If the insert method is used to continuously insert a large area of rectangles, and each rectangle overlaps with four sub nodes, the insert method will be infinitely recursive

@timohausmann
Copy link
Owner

timohausmann commented Nov 11, 2023

I see that insert runs very often but not infinitely, can you provide an example? It takes a long time to insert 100 objects that fill all nodes, maybe you could lower the max_levels or in that case the Quadtree isn't the right choice.

var amount = 100;
var width = 800;
var height = 600;
var max_objects = 10;
var max_levels = 4;

var myTree = new Quadtree({
	x: 0,
	y: 0,
	width: width,
	height: height
}, max_objects, max_levels);

var start = window.performance.now();
for(var i=0; i<amount;i++) {
	myTree.insert({
		x: 50,
		y: 50,
		width: width-100,
		height: height-100,
	});
}
var end = window.performance.now();
var time = end - start;
console.log('done inserting', amount, 'objects in', time, 'ms');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants