Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quadtree traversal

I'm trying to implement a forward iterator for a quadtree. Unfortunately I don't seem to be able to find any resource about traversal in a quadtree.

Can anybody point me in the right direction?

like image 315
Matt Mils Avatar asked Feb 03 '12 17:02

Matt Mils


People also ask

What is quadtree in data structure?

A quadtree is a tree data structure in which each internal node has exactly four children. Quadtrees are the two-dimensional analog of octrees and are most often used to partition a two-dimensional space by recursively subdividing it into four quadrants or regions.

What is quadtree in image processing?

The quadtree is an approach to image representation based on successive subdivision of the array into quadrants. In essence, the array is repeatedly subdivided into quadrants until blocks are obtained (possibly single pixels) which consist of entirely the same type of pixels.

What is a quadtree used for?

Quadtrees are used in image compression, where each node contains the average colour of each of its children. The deeper you traverse in the tree, the more the detail of the image. Quadtrees are also used in searching for nodes in a two-dimensional area.

What is quadtree for collision?

Quadtree is a way of partitioning space so that it's easy to traverse and search. A quadtree recursively partitions two-dimensional space into squares, dividing each square into four equally-sized squares. Each distinct data point exists in a unique leaf node; Coincident points are represented by a linked list.


2 Answers

An easy way is to linearize the tree. You'll have to do it recursively, of course, but you'll make an array of pointers to the nodes you want to visit and then create a forward iterator from that.

like image 181
Pochi Avatar answered Sep 18 '22 15:09

Pochi


Take a gander at the following paper and see if it has what you need...

Simple and Efficient Traversal Methods for Quadtrees and Octrees

like image 30
hatboyzero Avatar answered Sep 18 '22 15:09

hatboyzero