四叉树遍历
我正在尝试为四叉树实现前向迭代器。不幸的是,我似乎无法找到任何有关四叉树遍历的资源。
有人能指出我正确的方向吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一个简单的方法是将树线性化。当然,您必须递归地执行此操作,但您将创建一个指向要访问的节点的指针数组,然后从中创建一个前向迭代器。
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
这是我在 javascript 中的实现:
https://github.com/alexroat/quadtree-traversal
有一个可视化演示,展示了算法的行为。
This is my implementation in javascript:
https://github.com/alexroat/quadtree-traversal
There is a visual demo that shows the behaviour of the algorithm.