Class RegionBSPTree1D

    • Field Detail

      • BOUNDARY_PAIR_COMPARATOR

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

      • RegionBSPTree1D

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

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

      • add

        public void add​(Interval 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
      • contains

        public boolean contains​(double x)
        Return true if the given point location is on the inside or boundary of the region.
        Parameters:
        x - the location to test
        Returns:
        true if the location is on the inside or boundary of the region
        See Also:
        Region.contains(org.apache.commons.geometry.core.Point)
      • getBoundarySize

        public double getBoundarySize()
        Get the size of the boundary of the region. The size is a value in the d-1 dimension space. For example, in Euclidean space, this will be a length in 2D and an area in 3D.

        This method simply returns 0 because boundaries in one dimension do not have any size.

        Specified by:
        getBoundarySize in interface Region<Vector1D>
        Overrides:
        getBoundarySize in class AbstractRegionBSPTree<Vector1D,​RegionBSPTree1D.RegionNode1D>
        Returns:
        the size of the boundary of the region
      • split

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

        When splitting trees representing single points with a splitter lying directly on the point, the result point is placed on one side of the splitter based on its orientation: if the splitter is positive-facing, the point is placed on the plus side of the split; if the splitter is negative-facing, the point is placed on the minus side of the split.

        Parameters:
        splitter - the hyperplane to split this object with.
        Returns:
        result of the split operation
      • getMin

        public double getMin()
        Get the minimum value on the inside of the region; returns Double.NEGATIVE_INFINITY if the region does not have a minimum value and Double.POSITIVE_INFINITY if the region is empty.
        Returns:
        the minimum value on the inside of the region
      • getMax

        public double getMax()
        Get the maximum value on the inside of the region; returns Double.POSITIVE_INFINITY if the region does not have a maximum value and Double.NEGATIVE_INFINITY if the region is empty.
        Returns:
        the maximum value on the inside of the region
      • toIntervals

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

        private Interval createInterval​(RegionBSPTree1D.BoundaryPair start,
                                        RegionBSPTree1D.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
      • visitInsideIntervals

        private void visitInsideIntervals​(java.util.function.BiConsumer<OrientedPoint,​OrientedPoint> visitor)
        Compute the min/max intervals for all interior convex regions in the tree and pass the values to the given visitor function.
        Parameters:
        visitor - the object that will receive the calculated min and max boundary for each insides node's convex region
      • swapsInsideOutside

        protected boolean swapsInsideOutside​(Transform<Vector1D> transform)
        Returns true if the given transform would result in a swapping of the interior and exterior of the region if applied.

        This method always returns false since no swapping of this kind occurs in 1D.

        Overrides:
        swapsInsideOutside in class AbstractBSPTree<Vector1D,​RegionBSPTree1D.RegionNode1D>
        Parameters:
        transform - transform to check
        Returns:
        true if the given transform swaps the interior and exterior of the region
      • from

        public static RegionBSPTree1D from​(Interval interval,
                                           Interval... more)
        Construct a new instance from one or more intervals. The returned tree represents the same region as the union of all of the input intervals.
        Parameters:
        interval - the input interval
        more - additional intervals to add to the region
        Returns:
        a new instance representing the same region as the union of all of the given intervals
      • from

        public static RegionBSPTree1D from​(java.lang.Iterable<Interval> intervals)
        Construct a new instance from the given collection of intervals.
        Parameters:
        intervals - the intervals to populate the region with
        Returns:
        a new instance constructed from the given collection of intervals
      • intervalToTree

        private static RegionBSPTree1D intervalToTree​(Interval interval)
        Return a tree representing the same region as the given interval.
        Parameters:
        interval - interval to create a tree from
        Returns:
        a tree representing the same region as the given interval