/// <summary> /// Return true if there are any nodes in this Quadrant that intersect the given bounds. /// </summary> /// <param name="bounds">The bounds to test</param> /// <returns>boolean</returns> public Boolean HasIntersectingNodes(RectangleF bounds) { if (bounds.IsEmpty) { return(false); } Single w = Bounds.Width / 2; Single h = Bounds.Height / 2; // assumption that the Rect struct is almost as fast as doing the operations // manually since Rect is a value type. RectangleF topLeft = new RectangleF(Bounds.Left, Bounds.Top, w, h); RectangleF topRight = new RectangleF(Bounds.Left + w, Bounds.Top, w, h); RectangleF bottomLeft = new RectangleF(Bounds.Left, Bounds.Top + h, w, h); RectangleF bottomRight = new RectangleF(Bounds.Left + w, Bounds.Top + h, w, h); Boolean found = false; // See if any child quadrants completely contain this node. if (topLeft.IntersectsWith(bounds) && TopLeft != null) { found = TopLeft.HasIntersectingNodes(bounds); } if (!found && topRight.IntersectsWith(bounds) && TopRight != null) { found = TopRight.HasIntersectingNodes(bounds); } if (!found && bottomLeft.IntersectsWith(bounds) && BottomLeft != null) { found = BottomLeft.HasIntersectingNodes(bounds); } if (!found && bottomRight.IntersectsWith(bounds) && BottomRight != null) { found = BottomRight.HasIntersectingNodes(bounds); } if (!found) { found = HasIntersectingNodes(Nodes, bounds); } return(found); }