コード例 #1
0
 /// <summary>
 /// Create an octree
 /// </summary>
 /// <param name="size"></param>
 public Octree(DepthsByDiameter maxDepth, TType defaultValue)
 {
     depth = maxDepth;
     root  = new OctreeNode <TType>(
         new Coordinate(0, 0, 0),
         (int)Math.Pow(2, (int)depth),
         defaultValue
         );
 }
コード例 #2
0
        /// <summary>
        /// Get a tree from the given node depth
        /// </summary>
        /// <param name="position">The position of the node to get</param>
        /// <param name="diameter">The diameter/depth of the child tree we are grabbing (how large it is, now how deep it is in the parent)</param>
        /// <returns></returns>
        public Octree <TType> getTreeAt(Coordinate position, DepthsByDiameter diameter)
        {
            int expectedSize = GetSizeOfNodeFromDepth(diameter);
            OctreeNode <TType> childTreeRootNode = root.getNodeAt(
                position,
                expectedSize
                );

            // trim the grabbed node to the selected size and push it into a tree as the root.
            childTreeRootNode.makeNodeRoot(expectedSize);
            return(new Octree <TType>(childTreeRootNode));
        }
コード例 #3
0
 /// <summary>
 /// Get the diameter of a node with the given depth.
 /// </summary>
 /// <param name="depth"></param>
 /// <returns>The size of node with the given max depth</returns>
 public static int GetSizeOfNodeFromDepth(DepthsByDiameter depth)
 {
     return((int)Math.Pow(2, (int)depth));
 }
コード例 #4
0
 /// <summary>
 /// Get the diameter of a node at the given depth of this tree using maths
 /// </summary>
 /// <param name="depth"></param>
 /// <returns></returns>
 int getNodeSizeAtDepth(DepthsByDiameter depth)
 {
     return((int)(root.size * (1 / Math.Pow(2, (int)depth))));
 }