Class RegionBSPTree1S

All Implemented Interfaces:
BSPSubtree<Point1S,RegionBSPTree1S.RegionNode1S>, BSPTree<Point1S,RegionBSPTree1S.RegionNode1S>, HyperplaneBoundedRegion<Point1S>, Splittable<Point1S,HyperplaneBoundedRegion<Point1S>>, Region<Point1S>, Sized

public class RegionBSPTree1S extends AbstractRegionBSPTree<Point1S,RegionBSPTree1S.RegionNode1S>
BSP tree representing regions in 1D spherical space.
  • Field Details

  • Constructor Details

    • 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 Details

    • copy

      public RegionBSPTree1S copy()
      Return a deep copy of this instance.
      Returns:
      a deep copy of this instance.
      See Also:
    • 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
    • project

      public Point1S project(Point1S pt)
      Project a point onto the boundary of the region. Null is returned if the region contains no boundaries (ie, is either full or empty).
      Specified by:
      project in interface Region<Point1S>
      Overrides:
      project in class AbstractRegionBSPTree<Point1S,RegionBSPTree1S.RegionNode1S>
      Parameters:
      pt - pt to project
      Returns:
      projection of the point on the boundary of the region or null if the region does not contain any boundaries
    • transform

      public void transform(Transform<Point1S> transform)
      Transform this tree. Each cut in the tree is transformed in place using the given Transform.

      Each interval of the region is transformed individually and the results are unioned. If the size of any transformed interval is greater than or equal to 2pi, then the region is set to the full space.

      Specified by:
      transform in interface BSPTree<Point1S,RegionBSPTree1S.RegionNode1S>
      Overrides:
      transform in class AbstractBSPTree<Point1S,RegionBSPTree1S.RegionNode1S>
      Parameters:
      transform - the transform to apply
    • 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:
    • 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 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(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

      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
    • computeRegionSizeProperties

      protected AbstractRegionBSPTree.RegionSizeProperties<Point1S> computeRegionSizeProperties()
      Compute the size-related properties of the region.
      Specified by:
      computeRegionSizeProperties in class AbstractRegionBSPTree<Point1S,RegionBSPTree1S.RegionNode1S>
      Returns:
      object containing size properties for the region
    • createNode

      protected RegionBSPTree1S.RegionNode1S createNode()
      Create a new node for this tree.
      Specified by:
      createNode in class AbstractBSPTree<Point1S,RegionBSPTree1S.RegionNode1S>
      Returns:
      a new node for this tree
    • 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