Class RegionBSPTree1S
- All Implemented Interfaces:
BSPSubtree<Point1S,
,RegionBSPTree1S.RegionNode1S> BSPTree<Point1S,
,RegionBSPTree1S.RegionNode1S> HyperplaneBoundedRegion<Point1S>
,Splittable<Point1S,
,HyperplaneBoundedRegion<Point1S>> Region<Point1S>
,Sized
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Internal class containing pairs of interval boundaries.private static final class
Class used to project points onto the region boundary.static final class
BSP tree node for one dimensional spherical space.Nested classes/interfaces inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree
AbstractRegionBSPTree.AbstractRegionNode<P extends Point<P>,
N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>>, AbstractRegionBSPTree.BoundaryProjector<P extends Point<P>, N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>>, AbstractRegionBSPTree.RegionSizeProperties<P extends Point<P>> Nested classes/interfaces inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree
AbstractBSPTree.AbstractNode<P extends Point<P>,
N extends AbstractBSPTree.AbstractNode<P, N>>, AbstractBSPTree.SubtreeInitializer<N extends AbstractBSPTree.AbstractNode<?, ?>> Nested classes/interfaces inherited from interface org.apache.commons.geometry.core.partitioning.bsp.BSPTree
BSPTree.FindNodeCutRule, BSPTree.Node<P extends Point<P>,
N extends BSPTree.Node<P, N>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Comparator
<RegionBSPTree1S.BoundaryPair> Comparator used to sort BoundaryPairs by ascending azimuth. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty instance.RegionBSPTree1S
(boolean full) Create a new region. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(AngularInterval interval) Add an interval to this region.Compute the size-related properties of the region.copy()
Return a deep copy of this instance.private AngularInterval
Create an interval instance from the min boundary from the start boundary pair and the max boundary from the end boundary pair.protected RegionBSPTree1S.RegionNode1S
Create a new node for this tree.static RegionBSPTree1S
empty()
Return a new, empty BSP tree.static RegionBSPTree1S
fromInterval
(AngularInterval interval) Return a new BSP tree representing the same region as the given angular interval.static RegionBSPTree1S
full()
Return a new, full BSP tree.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.private RegionBSPTree1S.BoundaryPair
Return the min/max boundary pair for the convex region represented by the given node.Project a point onto the boundary of the region.private static void
safeUnion
(RegionBSPTree1S target, RegionBSPTree1S input) Perform a union operation withtarget
andinput
, storing the result intarget
; does nothing ifinput
is null.split
(Hyperplane<Point1S> splitter) Split this instance with the given hyperplane.splitDiameter
(CutAngle splitter) Split the instance along a circle diameter.The diameter is defined by the given split point and its reversed antipodal point.Convert the region represented by this tree into a list of separateAngularInterval
s, arranged in order of ascending min value.void
Transform this tree.Methods inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree
boundaries, classify, complement, complement, condense, copyNodeProperties, createBoundaryIterable, createBoundaryList, difference, difference, getBoundaries, getBoundarySize, getCentroid, getRegionSizeProperties, getSize, getSubtreeInitializer, insert, insert, insert, insert, insert, insert, insert, insert, intersection, intersection, invalidate, isEmpty, isFull, setEmpty, setFull, split, union, union, xor, xor
Methods inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree
accept, accept, copy, copyNode, copySubtree, count, cutNode, extract, extractParentPath, findNode, findNode, getRoot, getVersion, height, importSubtree, insert, nodes, removeNodeCut, setNodeCut, setRoot, splitIntoTrees, splitSubtree, swapsInsideOutside, toString, treeString, treeString, trimToNode
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.geometry.core.Sized
isFinite, isInfinite
-
Field Details
-
BOUNDARY_PAIR_COMPARATOR
Comparator used to sort BoundaryPairs by ascending azimuth.
-
-
Constructor Details
-
RegionBSPTree1S
public RegionBSPTree1S()Create a new, empty instance. -
RegionBSPTree1S
public RegionBSPTree1S(boolean full) Create a new region. Iffull
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
Return a deep copy of this instance.- Returns:
- a deep copy of this instance.
- See Also:
-
add
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
Project a point onto the boundary of the region. Null is returned if the region contains no boundaries (ie, is eitherfull
orempty
).- Specified by:
project
in interfaceRegion<Point1S>
- Overrides:
project
in classAbstractRegionBSPTree<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
Transform this tree. Each cut in the tree is transformed in place using the givenTransform
.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 interfaceBSPTree<Point1S,
RegionBSPTree1S.RegionNode1S> - Overrides:
transform
in classAbstractBSPTree<Point1S,
RegionBSPTree1S.RegionNode1S> - Parameters:
transform
- the transform to apply
-
split
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)
, wherex
is the location of the hyperplane. For example, a positive-facingCutAngle
instance with an azimuth of0.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-facingCutAngle
with an azimuth of0pi
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 at0pi
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
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
Convert the region represented by this tree into a list of separateAngularInterval
s, arranged in order of ascending min value.- Returns:
- list of
AngularInterval
s representing this region in order of ascending min value
-
getIntervalStartIndex
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, or0
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 pairend
- 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
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
Compute the size-related properties of the region.- Specified by:
computeRegionSizeProperties
in classAbstractRegionBSPTree<Point1S,
RegionBSPTree1S.RegionNode1S> - Returns:
- object containing size properties for the region
-
createNode
Create a new node for this tree.- Specified by:
createNode
in classAbstractBSPTree<Point1S,
RegionBSPTree1S.RegionNode1S> - Returns:
- a new node for this tree
-
empty
Return a new, empty BSP tree.- Returns:
- a new, empty BSP tree.
-
full
Return a new, full BSP tree. The returned tree represents the full space.- Returns:
- a new, full BSP tree.
-
fromInterval
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
Perform a union operation withtarget
andinput
, storing the result intarget
; does nothing ifinput
is null.- Parameters:
target
- target treeinput
- input tree
-