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?
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?
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.
Take a gander at the following paper and see if it has what you need...
Simple and Efficient Traversal Methods for Quadtrees and Octrees
This is my implementation in javascript: https://github.com/alexroat/quadtree-traversal
There is a visual demo that shows the behaviour of the algorithm.
© 2022 - 2024 — McMap. All rights reserved.