Giter Site home page Giter Site logo

up-search-quadtree's Introduction

Up-search Quadtree

This repository aims to show a new method by upward searching for efficiently searching a quadtree.

Principle

The combination of a loose quadtree with a multilayer grid enables O(1) time complexity for insertion. Based on this feature, we can rapidly determine the insertion position for the search region. From this point upwards to the top, the path is predetermined, requiring only the search of a 3x3 area along this path. Consequently, a significant number of intersection checks can be skipped. For the remaining levels, the coordinates of nodes intersecting with the search region can be directly calculated, eliminating the need for individually checking each node for intersection.

Advantages

  • Very fast search
  • Smaller size for each node
  • Items found are relatively ordered in terms of size

Disadvantages

  • Low space utilization when there are fewer entities
  • Looseness can only be 2

Quadtrees Included in This Repository

quadtree.rs is a normal quadtree implementation. grid_loose_quadtree.rs is a loose quadtree combined with a multilayers grid, which also implements the up-search function. Additionally, up_search_quadtree.rs is the result obtained by retaining only the up-search function and optimization based on grid_loose_quadtree.rs.

grid_loose_quadtree_original.rs is the original idea of up-search quadtree, which achieves O(1) insertion on a regular (non-loose) quadtree by an O(1) lowest common ancestor finding approach. Although using the up-search method, there is basically no performance improvement. However, this file may be helpful in understanding the up-search method, as it is simpler than the current version.

Benchmark

cargo bench

Search 10000 times among 10000 balls of different sizes using the bounds of each of them:

Quadtree GridLooseQuadtree UpSearchQuadtree
7.08ms 4.79ms 2.82ms

Of these, the first two results are obtained using the traditional method.

up-search-quadtree's People

Contributors

redgeioz avatar

Stargazers

grislux55 avatar  avatar

Watchers

 avatar

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.