Class RegionBSPTree1S

    • Field Detail

      • BOUNDARY_PAIR_COMPARATOR

        private static final java.util.Comparator<RegionBSPTree1S.BoundaryPair> BOUNDARY_PAIR_COMPARATOR
        Comparator used to sort BoundaryPairs by ascending azimuth.
    • Constructor Detail

      • RegionBSPTree1S

        public RegionBSPTree1S()
        Create a new, empty instance.
      • RegionBSPTree1S

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

      • add

        public void add​(AngularInterval interval)
        Add an interval to this region. The resulting region will be the union of the interval and the region represented by this instance.
        Parameters:
        interval - the interval to add
      • split

        public Split<RegionBSPTree1S> split​(Hyperplane<Point1S> splitter)
        Split this instance with the given hyperplane.

        It is important to note that split operations occur according to the rules of the CutAngle hyperplane class. In this class, the continuous circle is viewed as a non-circular segment of the number line in the range [0, 2pi). Hyperplanes are placed along this line and partition it into the segments [0, x] and [x, 2pi), where x is the location of the hyperplane. For example, a positive-facing CutAngle instance with an azimuth of 0.5pi has a minus side consisting of the angles [0, 0.5pi] and a plus side consisting of the angles [0.5pi, 2pi). Similarly, a positive-facing CutAngle with an azimuth of 0pi has a plus side of [0, 2pi) (the full space) and a minus side that is completely empty (since no points exist in our domain that are less than zero). These rules can result in somewhat non-intuitive behavior at times. For example, splitting a non-empty region with a hyperplane at 0pi is essentially a no-op, since the region will either lie entirely on the plus or minus side of the hyperplane (depending on the hyperplane's orientation) regardless of the actual content of the region. In these situations, a copy of the tree is returned on the appropriate side of the split.

        Parameters:
        splitter - the hyperplane to split this object with.
        Returns:
        result of the split operation
        See Also:
        CutAngle, splitDiameter(CutAngle)
      • splitDiameter

        public Split<RegionBSPTree1S> splitDiameter​(CutAngle splitter)
        Split the instance along a circle diameter.The diameter is defined by the given split point and its reversed antipodal point.
        Parameters:
        splitter - split point defining one side of the split diameter
        Returns:
        result of the split operation
      • toIntervals

        public java.util.List<AngularInterval> toIntervals()
        Convert the region represented by this tree into a list of separate AngularIntervals, arranged in order of ascending min value.
        Returns:
        list of AngularIntervals representing this region in order of ascending min value
      • getIntervalStartIndex

        private int getIntervalStartIndex​(java.util.List<RegionBSPTree1S.BoundaryPair> boundaryPairs)
        Get the index that should be used as the starting point for combining adjacent boundary pairs into contiguous intervals. This is computed as the first boundary pair found that is not connected to the pair before it, or 0 if no such entry exists.
        Parameters:
        boundaryPairs - list of boundary pairs to search; must be ordered by increasing azimuth
        Returns:
        the index to use as a starting place for combining adjacent boundary pairs into contiguous intervals
      • createInterval

        private AngularInterval createInterval​(RegionBSPTree1S.BoundaryPair start,
                                               RegionBSPTree1S.BoundaryPair end)
        Create an interval instance from the min boundary from the start boundary pair and the max boundary from the end boundary pair. The hyperplane directions are adjusted as needed.
        Parameters:
        start - starting boundary pair
        end - ending boundary pair
        Returns:
        an interval created from the min boundary of the given start pair and the max boundary from the given end pair
      • getNodeBoundaryPair

        private RegionBSPTree1S.BoundaryPair getNodeBoundaryPair​(RegionBSPTree1S.RegionNode1S node)
        Return the min/max boundary pair for the convex region represented by the given node.
        Parameters:
        node - the node to compute the interval for
        Returns:
        the min/max boundary pair for the convex region represented by the given node
      • empty

        public static RegionBSPTree1S empty()
        Return a new, empty BSP tree.
        Returns:
        a new, empty BSP tree.
      • full

        public static RegionBSPTree1S full()
        Return a new, full BSP tree. The returned tree represents the full space.
        Returns:
        a new, full BSP tree.
      • fromInterval

        public static RegionBSPTree1S fromInterval​(AngularInterval interval)
        Return a new BSP tree representing the same region as the given angular interval.
        Parameters:
        interval - the input interval
        Returns:
        a new BSP tree representing the same region as the given angular interval
      • safeUnion

        private static void safeUnion​(RegionBSPTree1S target,
                                      RegionBSPTree1S input)
        Perform a union operation with target and input, storing the result in target; does nothing if input is null.
        Parameters:
        target - target tree
        input - input tree