Exemplo n.º 1
0
 private RegionQuadTree <T> GetMostNorthEastRecursive(RegionQuadTree <T> p)
 {
     if (!p.IsLeaf)
     {
         return(GetMostNorthEastRecursive(p.Childs[3]));
     }
     return(p);
 }
Exemplo n.º 2
0
 private LinearNode <T> NodeOf(RegionQuadTree <T> region)
 {
     foreach (LinearNode <T> node in _q)
     {
         if (node.Region == region)
         {
             return(node);
         }
     }
     return(null);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LinearQuadTree{T}" /> class.
        /// </summary>
        /// <param name="root">The root node.</param>
        public LinearQuadTree(RegionQuadTree <T> root)
        {
            _maxLevel  = root.TreeHeight - 1;
            this._root = root;
            Int64 ptx = 0;

            for (Int32 i = 0; i <= _maxLevel; i++)
            {
                ptx += Convert.ToInt64(Math.Pow(4, Convert.ToDouble(i)));
            }
            _tx   = ptx;
            _ty   = _tx << 1;
            _dw   = Encode(-1, 0, _maxLevel);
            _ds   = Encode(0, -1, _maxLevel);
            _de   = Encode(1, 0, _maxLevel);
            _dn   = Encode(0, 1, _maxLevel);
            _mask = Convert.ToInt64(Math.Pow(4, _maxLevel)) - 1;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Divides the node into four child nodes.
        /// </summary>
        public void Subdivide()
        {
            if (CanDivide)
            {
                _childs = new RegionQuadTree <T> [4];
                Double childWidth  = Width / 2;
                Double childHeight = Height / 2;

                _childs[2]        = new RegionQuadTree <T>(X, Y, childWidth, childHeight);
                _childs[2].Parent = this;
                _childs[3]        = new RegionQuadTree <T>(X + childWidth, Y, childWidth, childHeight);
                _childs[3].Parent = this;
                _childs[0]        = new RegionQuadTree <T>(X, Y + childHeight, childWidth, childHeight);
                _childs[0].Parent = this;
                _childs[1]        = new RegionQuadTree <T>(X + childWidth, Y + childHeight, childWidth, childHeight);
                _childs[1].Parent = this;

                this.TreeHeight += 1;
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinearNode{T}" /> class.
 /// </summary>
 /// <param name="node">The region suadtree node.</param>
 /// <param name="code">The code.</param>
 public LinearNode(RegionQuadTree <T> node, Int64 code)
 {
     Region = node;
     Code   = code;
 }