Code Monkey home page Code Monkey logo

Comments (3)

timohausmann avatar timohausmann commented on May 16, 2024

Hey, again sorry for the late response, didn't see the issues here.
This may be intended use and a misunderstanding. Some example code would be awesome.

What I understood you tried to achieve something like this? http://jsfiddle.net/ua9203zb/2/
It has a 4000x4000 area with 4x4 possible quadtrees, limited by the max_levels of 2.
The top left 1000x1000 is constantly retrieved and those objects are highlighted in white.
(Draw functions are scaled down by 10)

from quadtree-js.

MarkusMiller avatar MarkusMiller commented on May 16, 2024

Yes, your setup is right and this screenshot shows, what I find unexpected with it:
http://s27.postimg.org/63s8wzt4z/Quadtree.png

But if I remember right, it just occures with non-point Items. It is totally fine, when you just use point-dimensional items

I modified your example a bit: http://jsfiddle.net/zwcckn5s/
All retrieved tiles are drawn in blue when you query for the upper left corner (0, 0, 1000, 1000)

from quadtree-js.

timohausmann avatar timohausmann commented on May 16, 2024

I did some updates on the code and came across this post one again.
Like I said in the other issue months ago, the screenshot shows intended behaviour since the Quadtree only narrows down the objects of possible collision.

The problem in your example is the dimensions of the objects, they are 1000x1000 units, aligned in a grid. Same grid as the Quadtree, I don't see the actual point in this? They cannot fit into one exact subnode, since they are same size. This is where the screenshot effect comes in: all objects touching a shared border with the retrieve area are possible candidates.

When you debug myTree in the given example, you see that all objects belong to the master node, the Quadtree itself.

I reduced the objects dimensions by 2 units, this way it works http://jsfiddle.net/zwcckn5s/1/
When you debug there, objects are stored in subnodes, the way it should be.

There are new examples and docs, maybe check them out.

from quadtree-js.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.