1 / 9

Quadtrees

Quadtrees. 1. Split along pre-defined planes Used to partition 2-D space In general, a quadtree is a tree in which each node has at most 4 children Each node of the tree corresponds to a square region

esterd
Download Presentation

Quadtrees

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Quadtrees 1

  2. Split along pre-defined planes • Used to partition 2-D space • In general, a quadtree is a tree in which each node has at most 4 children • Each node of the tree corresponds to a square region • If a node has children, think of its region being chopped into 4 equal subregions. Child nodes correspond to these smaller subregions of their parent’s region • Subdivide as little or as much as necessary • Each internal node has exactly 4 children Background

  3. The root node of a quadtree corresponds to a square region in space. • Generally, this encompasses the entire “region of interest”. • If desired, subdivide along lines parallel to the coordinate axes, forming four smaller identically sized square regions. The child nodes correspond to these. • Some or all of these children may be subdivided further. • Octrees work in a similar fashion, but in 3-D, with cubical regions subdivided into 8 parts. A A A A B C B C D E D E A A B C Quadtree Example B C D E D E F G F G H I H I

  4. Two objects that are at opposite ends of the screen can not possibly collide, so there is no need to check for a collision between them. We can use quadtree to reduce the number of checks. A quadtree starts as a single node. Objects added to the quadtree are added to the single node. Collision Detection

  5. When more objects are added to the quadtree, it will eventually split into four subnodes. Each object will then be put into one of these subnodes according to where it lies in the 2D space. Any object that cannot fully fit inside a node’s boundary will be placed in the parent node. Collision Detection Each subnode can continue subdividing as more objects are added

  6. As you can see, each node only contains a few objects. We know then that, for instance, the objects in the top-left node cannot be colliding with the objects in the bottom-right node, so we don't need to run an expensive collision detection algorithm between such pairs. Collision Detection

  7. Actual objects stored inside the leaves, not inner nodes. • Insert an object into the quadtree Check if the object intersects the current node. If so, recurse. If you've reached the leaf level, insert the object into the collection. • Delete an object from the quadtree Execute the exact same steps as if inserting the object, but when you've reached the leaf level delete it from the collection. • Test if an object intersects any object inside the quadtree Execute the exact same steps as if inserting the object, but when you've reached the leaf level check for collision with all the objects in the collection. • Test for all collisions between all objects inside the quadtree For every object in the quadtree execute the single object collision test. • Update the quadtree Delete all objects from the quadtree whose position has been modified and insert them again. Implementation of the Operations

  8. ?

  9. References

More Related