public bool BoundryContains(QuadTreeElement <T> p) { return (p.X >= X && p.X <= X + Width && p.Y >= Y && p.Y <= Y + Height); }
public bool Insert(QuadTreeElement <T> p) { if (!boundry.BoundryContains(p)) { return(false); } if (points.Count < capacity) { points.Add(p); return(true); } else { if (!subdivided) { Subdivide(); } if (topLeft.Insert(p)) { return(true); } else if (topRight.Insert(p)) { return(true); } else if (bottomLeft.Insert(p)) { return(true); } else if (bottomRight.Insert(p)) { return(true); } return(false); } }