public void range(Node <Point2D, V> temp, RectHV rect, List <Point2D> t) { if (temp == null) { return; } if (rect.Contains(temp.Key)) { t.Add(temp.Key); } IComparer <Point2D> comparer = (IComparer <Point2D>) new XPoint2DComparer(); if (temp.depth % 2 == 1) { comparer = (IComparer <Point2D>) new YPoint2DComparer(); } if (temp.depth % 2 == 1) { if (rect.ContainsInY(temp.Key) > 0) { range(temp.left, rect, t); } else if (rect.ContainsInY(temp.Key) < 0) { range(temp.right, rect, t); } else { range(temp.left, rect, t); range(temp.right, rect, t); } } else { if (rect.ContainsInX(temp.Key) > 0) { range(temp.left, rect, t); } else if (rect.ContainsInX(temp.Key) < 0) { range(temp.right, rect, t); } else { range(temp.left, rect, t); range(temp.right, rect, t); } } }
//public void draw() // draw all points to standard draw // all points that are inside the rectangle (or on the boundary) public IEnumerator <Point2D> range(RectHV rect) { List <Point2D> inRangePoints = new List <Point2D>(); foreach (var p in set) { if (rect.Contains(p)) { inRangePoints.Add(p); } } return(inRangePoints.GetEnumerator()); }
// does this rectangle intersect that rectangle (at one or more points)? public bool Intersects(RectHV that) { return((this.Contains(new Point2D(xmin(), ymin()))) || (this.Contains(new Point2D(xmax(), ymax()))) || (that.Contains(new Point2D(that.xmin(), that.ymin()))) || (that.Contains(new Point2D(that.xmax(), that.ymax())))); }