现在的位置: 首页 > 综合 > 正文

KD-Tree 的资料整理

2012年04月27日 ⁄ 综合 ⁄ 共 3240字 ⁄ 字号 评论关闭

声明:以下资料均为网络整理所得

 

【1】百度百科:

 

     KD-Tree是一种由二叉搜索树推广而来的用于多维检索的树的结构形式(K即为空间的维数)。
    
     它与二叉搜索树不同的是它的每个结点表示k维空间的一个点,并且每一层都根据该层的分辨器(discriminator)对相应对象做出分枝决策。顶层结点按由分辨器决定的一个维度进行划分,第二层则按照该层的分辨器决定的一个维进行划分...以此类推在余下各维之间不断地划分。直至一个结点中的点数少于给定的最大点数时,结束划分。

 

  KD-Tree的分辨器根据不同的用途会有不同的分辨器,最普通的分辨器为:n mod k(树的根节点所在层为第0层,根结点孩子所在层为第1层,以此类推)

 

作者注释:比如三维情况,用xyz坐标垂直面轮流切割包围盒,那么K=3,N MOD K = 0,1,2 就是XYZ三坐标的代号(分辨器)。


  即:若它的左子树非空,则其左子树上所有结点的第i维值均小于其根结点的第i维值;

 

  若它的右子树非空,则其右子树上所有结点的第i维值均大于其根结点的第i维值;并且它的左右子树也分别为KD-Tree。

 

【2】http://hi.baidu.com/briansj/blog/item/5acf9ae6cfc88c24b938202d.html

 

   K-Dimension tree,实际上是一棵平衡二叉树

 

 

一般的KD-Tree构造过程:

function kdtree (list of points pointList, int depth)

{

    if pointList is empty

        return nil;

    else {

        // Select axis based on depth so that axis cycles through all valid values

        var int
axis
:= depth mod k;

        // Sort point list and choose median as pivot element

        select median by
axis
from pointList;

        // Create node and construct subtrees

        var tree_node node;

        node.location := median;

        node.leftChild := kdtree(points in pointList before median, depth+1);

        node.rightChild := kdtree(points in pointList after median, depth+1);

        return node;

    }

}

 

 

 

【3】KD-Tree Based Fast Ray Tracing for RCS Prediction :

 

It is clear that the optimal splitting position is the one where the estimated cost CN is minimal 为的是使估算的开销最小, which can only be obtained at a split position that is coincident with one of the planes of the patch’s bounding box 切割位置需要与包围盒的边界一致. As a result,
split candidates are the bounding planes of patches inside the node. 候选的切割面是节点内部面片的边界。

 

作者注释:切割面的空间位置选择,最好沿着三角面片的边缘切,把空间一分为二。

 

 

 

 ……

The process to search the optimal split position of one axis is described as follows:

 

1:

The split candidates are initialized by projecting the bounding boxes of associated patches onto this axis. Each  bounding box has two split candidates, and each candidate contains the position on this axis, the flag that  represents the start or end of a
bounding box, and the patch it belongs to.

初始化:面片的包围盒投影到坐标轴上,每个包围盒产生了两个候选切割面(投影后最大值,最小值,例如上图a1,a2),候选(切割面)包含的信息有:在坐标轴的位置,起始或结尾的标识,所属片元的ID.

2:

Sort these split candidates from low to high along the axis.

排序:将候选切割面按照坐标值大小从小到大排序。

3:

Sweep across the sorted split candidates iteratively, incrementally update the patch number of children nodes, and
compute the estimated cost of each split candidate.

扫描:遍历刚刚排好序的候选切割面,相应的更新孩子节点的片元数量,并且估算每个候选面对应的开销

4:

Output the position of the split candidate with the minimal cost.

输出:找到最小开销对应的面片

 

【关于"compute the estimated cost of each split candidate":】如何估算候选面对应的开销

    

 

nl ,nr孩子节点包含片元的数量。

 

 

【4】http://blog.csdn.net/rickArkin/archive/2007/11/29/1907665.aspx

 

     事实上,kd-tree与八叉树(octree)都是二叉树(BSP)的变种。在三维图形应用,诸如碰撞检测,遮挡剔除以及光线追踪等领域,都可以通过对三维场景中的图元数据进行层次化细分,从而加速数据的遍历与检测过程。

  • 二叉树指用一个平面对场景的包围盒进行分割,然后将几何图元分别放置在两个子块中,由于二叉树中采用的分割平面可以是任意的,所以分割后的子块常常是不规则的。
  • kd-tree的划分中将分割平面限定为必须与某个坐标轴垂直;
  • 而八叉树则在每次分割时采用三个正交平面对空间进行等分。

     二叉树的划分过于随意,在应用中处理比较麻烦,而八叉树相对规则,处理起来要容易的多,但是由于要对空间进行等分,所以每个子块对图元的包围不够紧密,在进行检测的过程中会降低处理的效率。所以有人提出了松散八叉树,也就是仍然采用正交的分割平面,但是允许子块间不相等且可以相互重叠,这虽然提高了对图元的包围,有利于检测过程的高效执行,但是也增加了结构的复杂性与处理的难度。
     相比之下,kd-tree的划分方法既有二叉树的结构简单的特点,又因为不要求对空间进行等分,所以相比八叉树能够更紧密的包围图元,所以正在被越来越多的人们关注。比如Stanford大学的人这几年就在研究如何利用kd-tree结构来优化运动场景内的三维空间数据的管理,从而在GPU内实现实时的光线追踪渲染。

 

 

【5】场景管理技术:KDTREE+遮挡剔除


http://blog.csdn.net/skybreaker/archive/2007/10/16/1828104.aspx

 

 

【6】

原创BSP空间分割两篇

http://blog.csdn.net/noslopforever/archive/2006/12/26/1463557.aspx 

http://blog.csdn.net/noslopforever/archive/2006/12/26/1463577.aspx 

 

 

 

 

抱歉!评论已关闭.