Class RegionBSPTree2D

    • Field Detail

      • boundaryPaths

        private java.util.List<LinePath> boundaryPaths
        List of line subset paths comprising the region boundary.
    • Constructor Detail

      • RegionBSPTree2D

        public RegionBSPTree2D()
        Create a new, empty region.
      • RegionBSPTree2D

        public RegionBSPTree2D​(boolean full)
        Create a new region. If full is true, then the region will represent the entire 2D space. Otherwise, it will be empty.
        Parameters:
        full - whether or not the region should contain the entire 2D space or be empty
    • Method Detail

      • getBoundaries

        public java.util.List<LineConvexSubset> getBoundaries()
        Return a list containing the boundaries of the region. Each boundary is oriented such that its plus side points to the outside of the region. The exact ordering of the boundaries is determined by the internal structure of the tree.
        Overrides:
        getBoundaries in class AbstractRegionBSPTree<Vector2D,​RegionBSPTree2D.RegionNode2D>
        Returns:
        a list of the boundaries of the region
      • getBoundaryPaths

        public java.util.List<LinePath> getBoundaryPaths()
        Get the boundary of the region as a list of connected line subset paths. The line subset are oriented such that their minus (left) side lies on the interior of the region.
        Returns:
        line subset paths representing the region boundary
      • add

        public void add​(ConvexArea area)
        Add a convex area to this region. The resulting region will be the union of the convex area and the region represented by this instance.
        Parameters:
        area - the convex area to add
      • toConvex

        public java.util.List<ConvexArea> toConvex()
        Return a list of ConvexAreas representing the same region as this instance. One convex area is returned for each interior leaf node in the tree.
        Returns:
        a list of convex areas representing the same region as this instance
      • toConvexRecursive

        private void toConvexRecursive​(RegionBSPTree2D.RegionNode2D node,
                                       ConvexArea nodeArea,
                                       java.util.List<? super ConvexArea> result)
        Recursive method to compute the convex areas of all inside leaf nodes in the subtree rooted at the given node. The computed convex areas are added to the given list.
        Parameters:
        node - root of the subtree to compute the convex areas for
        nodeArea - the convex area for the current node; this will be split by the node's cut hyperplane to form the convex areas for any child nodes
        result - list containing the results of the computation
      • linecast

        public java.util.List<LinecastPoint2D> linecast​(LineConvexSubset subset)
        Intersect the given line subset against the boundaries in this instance, returning a list of all intersections in order of increasing position along the line. An empty list is returned if no intersections are discovered.
        Specified by:
        linecast in interface BoundarySource2D
        Specified by:
        linecast in interface Linecastable2D
        Parameters:
        subset - line subset to intersect
        Returns:
        a list of computed intersections in order of increasing position along the line
      • linecastFirst

        public LinecastPoint2D linecastFirst​(LineConvexSubset subset)
        Intersect the given line subset against the boundaries in this instance, returning the first intersection found when traveling in the direction of the line subset from its start location.
        Specified by:
        linecastFirst in interface BoundarySource2D
        Specified by:
        linecastFirst in interface Linecastable2D
        Parameters:
        subset - line subset to intersect
        Returns:
        the first intersection found or null if no intersection is found
      • computeBoundaryPaths

        private java.util.List<LinePath> computeBoundaryPaths()
        Compute the line subset paths comprising the region boundary.
        Returns:
        the line subset paths comprising the region boundary
      • from

        public static RegionBSPTree2D from​(java.lang.Iterable<? extends LineConvexSubset> boundaries)
        Construct a new tree from the given boundaries. If no boundaries are present, the returned tree is empty.
        Parameters:
        boundaries - boundaries to construct the tree from
        Returns:
        a new tree instance constructed from the given boundaries
        See Also:
        from(Iterable, boolean)
      • from

        public static RegionBSPTree2D from​(java.lang.Iterable<? extends LineConvexSubset> boundaries,
                                           boolean full)
        Construct a new tree from the given boundaries. If full is true, then the initial tree before boundary insertion contains the entire space. Otherwise, it is empty.
        Parameters:
        boundaries - boundaries to construct the tree from
        full - if true, the initial tree will contain the entire space
        Returns:
        a new tree instance constructed from the given boundaries