Exemple #1
0
        private void QueryRange(QuadTreeBoundingBox area, ref List <int> pointList)
        {
            if (!area.Overlaps(_boundary))
            {
                return;
            }


            for (int i = 0; i < _countPoints; i++)
            {
                if (area.ContainsPoint(_quadTreePoints[i]))
                {
                    pointList.Add(_quadTreePoints[i].Index);
                }
            }

            if (UpperLeft == null)
            {
                return;
            }

            UpperLeft.QueryRange(area, ref pointList);
            UpperRight.QueryRange(area, ref pointList);
            LowerLeft.QueryRange(area, ref pointList);
            LowerRight.QueryRange(area, ref pointList);
        }
Exemple #2
0
        public List <int> QueryRange(QuadTreeBoundingBox area)
        {
            List <int> includedPoints = new List <int>();

            QueryRange(area, ref includedPoints);

            return(includedPoints);
        }
Exemple #3
0
 public bool Overlaps(QuadTreeBoundingBox b)
 {
     if (Center.X + HalfLength.X < b.Center.X - b.HalfLength.X)
     {
         return(false);
     }
     if (Center.X - HalfLength.X > b.Center.X + b.HalfLength.X)
     {
         return(false);
     }
     if (Center.Y + HalfLength.Y < b.Center.Y - b.HalfLength.Y)
     {
         return(false);
     }
     if (Center.Y - HalfLength.Y > b.Center.Y + b.HalfLength.Y)
     {
         return(false);
     }
     return(true);
 }
Exemple #4
0
 public QuadTree(QuadTreeBoundingBox boundary)
 {
     _boundary       = boundary;
     _quadTreePoints = new QuadTreePointStruct[NODE_CAPACITY];
     _countPoints    = 0;
 }