public void IntersectsWith_test( int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2, bool intersects) { Hyperrectangle r1 = new Hyperrectangle(x1, y1, w1, h1); Hyperrectangle r2 = new Hyperrectangle(x2, y2, w2, h2); RectangleF f1 = new RectangleF(x1, y1, w1, h1); RectangleF f2 = new RectangleF(x2, y2, w2, h2); bool expected = f1.IntersectsWith(f2); bool actual = r1.IntersectsWith(r2); Assert.AreEqual(expected, actual); Assert.AreEqual(expected, intersects); }
public void IntersectsWith_test( double x1, double y1, double w1, double h1, double x2, double y2, double w2, double h2, bool intersects) { Hyperrectangle r1 = new Hyperrectangle(x1, y1, w1, h1); Hyperrectangle r2 = new Hyperrectangle(x2, y2, w2, h2); RectangleF f1 = new RectangleF((float)x1, (float)y1, (float)w1, (float)h1); RectangleF f2 = new RectangleF((float)x2, (float)y2, (float)w2, (float)h2); bool expected = f1.IntersectsWith(f2); bool actual = r1.IntersectsWith(r2); Assert.AreEqual(expected, actual); Assert.AreEqual(expected, intersects); }
private IList <TNode> getNodesInsideRegion(TNode node, Hyperrectangle region, Hyperrectangle subRegion) { var result = new List <TNode>(); if (node != null && region.IntersectsWith(subRegion)) { if (region.Contains(node.Position)) { result.Add(node); } result.AddRange(getNodesInsideRegion(node.Left, region, leftRect(subRegion, node))); result.AddRange(getNodesInsideRegion(node.Right, region, rightRect(subRegion, node))); } return(result); }