コード例 #1
0
ファイル: QuadTreeNode.cs プロジェクト: alexfordc/Au
        public QuadTreeNode CreateNewRoot(QuadTreeNode currentRoot)
        {
            var bounds   = currentRoot.Bounds;
            int startRow = bounds.Start.Row;
            int startCol = bounds.Start.Column;
            int halfCol  = bounds.ColumnsCount;
            int halfRow  = bounds.RowsCount;
            var Depth    = currentRoot.Depth;
            var QuadTree = currentRoot.QuadTree;

            var newRoot = new QuadTreeNode(
                new GridRange(startRow, startCol, halfCol * 2, halfRow * 2),
                currentRoot.Depth, currentRoot.QuadTree);


            newRoot.Nodes.Add(currentRoot);
            newRoot.Nodes.Add(new QuadTreeNode(GridRange.From(
                                                   new Position(startRow, startCol + halfCol),
                                                   halfRow, halfCol), Depth, QuadTree));
            newRoot.Nodes.Add(new QuadTreeNode(GridRange.From(
                                                   new Position(startRow + halfRow, startCol),
                                                   halfRow, halfCol), Depth, QuadTree));
            newRoot.Nodes.Add(new QuadTreeNode(GridRange.From(
                                                   new Position(startRow + halfRow, startCol + halfCol),
                                                   halfRow, halfCol), Depth, QuadTree));
            return(newRoot);
        }
コード例 #2
0
ファイル: QuadTreeNode.cs プロジェクト: alexfordc/Au
        public void CreateSubNodes(QuadTreeNode parentNode)
        {
            var m_bounds = parentNode.Bounds;

            // the smallest subnode has an area
            if ((parentNode.Bounds.ColumnsCount * parentNode.Bounds.RowsCount) <= 10)
            {
                return;
            }

            int startRow = m_bounds.Start.Row;
            int startCol = m_bounds.Start.Column;
            int halfCol  = (m_bounds.ColumnsCount / 2);
            int halfRow  = (m_bounds.RowsCount / 2);

            var Depth    = parentNode.Depth;
            var QuadTree = parentNode.QuadTree;

            parentNode.Nodes.Add(new QuadTreeNode(GridRange.From(m_bounds.Start, halfRow, halfCol), Depth, QuadTree));
            parentNode.Nodes.Add(new QuadTreeNode(GridRange.From(
                                                      new Position(startRow, startCol + halfCol),
                                                      halfRow, halfCol), Depth, QuadTree));
            parentNode.Nodes.Add(new QuadTreeNode(GridRange.From(
                                                      new Position(startRow + halfRow, startCol),
                                                      halfRow, halfCol), Depth, QuadTree));
            parentNode.Nodes.Add(new QuadTreeNode(GridRange.From(
                                                      new Position(startRow + halfRow, startCol + halfCol),
                                                      halfRow, halfCol), Depth, QuadTree));
        }
コード例 #3
0
ファイル: QuadTreeNode.cs プロジェクト: alexfordc/Au
        private void CreateNotProportionate(QuadTreeNode parentNode)
        {
            var m_bounds = parentNode.Bounds;
            int startRow = m_bounds.Start.Row;
            int startCol = m_bounds.Start.Column;
            int halfCol  = m_bounds.ColumnsCount;
            int halfRow  = (m_bounds.RowsCount / 2);

            var Depth    = parentNode.Depth;
            var QuadTree = parentNode.QuadTree;

            parentNode.Nodes.Add(new QuadTreeNode(GridRange.From(m_bounds.Start, halfRow, halfCol), Depth, QuadTree));
            parentNode.Nodes.Add(new QuadTreeNode(GridRange.From(
                                                      new Position(startRow + halfRow, startCol),
                                                      halfRow, halfCol), Depth, QuadTree));
        }