protected sealed override GenericPartitionTreeSection <BoundingRectangle, T> Expand(T target, Point2D director) { var min = Root.Boundary.Min; var max = Root.Boundary.Max; var size = new Point2D(Root.Boundary.Width, Root.Boundary.Height); var newMin = Point2D.Minimize(min, min + director * size); var newMax = Point2D.Maximize(max, max + director * size); var newRoot = new GenericPartitionTreeSection <BoundingRectangle, T>(new BoundingRectangle(newMin, newMax)); AddSubsection(newRoot, Root); for (var x = 0; x < 2; x++) { for (var y = 0; y < 2; y++) { if (x == 0 && y == 0) { continue; } var sectionMin = min + director * new Point2D(x, y) * size; var sectionMax = max + director * new Point2D(x, y) * size; var boundary = new BoundingRectangle(sectionMin, sectionMax); var subsection = new GenericPartitionTreeSection <BoundingRectangle, T>(boundary); AddSubsection(newRoot, subsection); } } if (newRoot == null) { throw new NullReferenceException(); } return(newRoot); }
protected sealed override void Subdivide(GenericPartitionTreeSection <BoundingRectangle, T> section) { var min = section.Boundary.Min; var halfSize = new Point2D(section.Boundary.Width, section.Boundary.Height) * 0.5f; for (var x = 0; x < 2; x++) { for (var y = 0; y < 2; y++) { var sectionMin = min + new Point2D(x, y) * halfSize; var sectionMax = min + new Point2D(x + 1, y + 1) * halfSize; var boundary = new BoundingRectangle(sectionMin, sectionMax); var subsection = new GenericPartitionTreeSection <BoundingRectangle, T>(boundary); AddSubsection(section, subsection); } } RedistributeItemsWithinSubsections(section); }
protected sealed override void Subdivide(GenericPartitionTreeSection <BoundingBox, T> section) { var box = section.Boundary; var min = box.Min; var halfSize = new Point3D(box.Width, box.Length, box.Height) * 0.5f; for (var x = 0; x < 2; x++) { for (var y = 0; y < 2; y++) { for (var z = 0; z < 2; z++) { var sectionMin = min + new Point3D(x, y, z) * halfSize; var sectionMax = min + new Point3D(x + 1, y + 1, z + 1) * halfSize; var boundary = new BoundingBox(sectionMin, sectionMax); var subsection = new GenericPartitionTreeSection <BoundingBox, T>(boundary); AddSubsection(section, subsection); } } } RedistributeItemsWithinSubsections(section); }
protected override bool SectionContains(GenericPartitionTreeSection <BoundingRectangle, Quad2D> section, Quad2D item) { return(section.Boundary.Intersects(item.Boundary)); }
protected override bool SectionContains(GenericPartitionTreeSection <BoundingRectangle, Point2D> section, Point2D item) { return(section.Boundary.Contains(item)); }
protected override bool SectionContains(GenericPartitionTreeSection <BoundingBox, Edge3D> section, Edge3D item) { return(section.Boundary.Intersects(item.Boundary)); }