Class RegionBSPTree1D
java.lang.Object
org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree<Vector1D,RegionBSPTree1D.RegionNode1D>
org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree<Vector1D,RegionBSPTree1D.RegionNode1D>
org.apache.commons.geometry.euclidean.oned.RegionBSPTree1D
- All Implemented Interfaces:
BSPSubtree<Vector1D,
,RegionBSPTree1D.RegionNode1D> BSPTree<Vector1D,
,RegionBSPTree1D.RegionNode1D> HyperplaneBoundedRegion<Vector1D>
,Splittable<Vector1D,
,HyperplaneBoundedRegion<Vector1D>> Region<Vector1D>
,Sized
public final class RegionBSPTree1D
extends AbstractRegionBSPTree<Vector1D,RegionBSPTree1D.RegionNode1D>
Binary space partitioning (BSP) tree representing a region in one dimensional
Euclidean space.
-
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.private static final class
Internal class for calculating the region of a single tree node.static final class
BSP tree node for one dimensional Euclidean space.private static final class
Internal class for calculating size-related properties for aRegionBSPTree1D
.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
<RegionBSPTree1D.BoundaryPair> Comparator used to sort BoundaryPairs by ascending location. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty region.RegionBSPTree1D
(boolean full) Create a new region. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an interval to this region.classify
(double x) Classify a point location with respect to the region.Compute the size-related properties of the region.boolean
contains
(double x) Return true if the given point location is on the inside or boundary of the region.copy()
Return a deep copy of this instance.private Interval
Create an interval instance from the min boundary from the start boundary pair and the max boundary from the end boundary pair.protected RegionBSPTree1D.RegionNode1D
Create a new node for this tree.static RegionBSPTree1D
empty()
Return a new, emptyRegionBSPTree1D
instance.static RegionBSPTree1D
Construct a new instance from the given collection of intervals.static RegionBSPTree1D
Construct a new instance from one or more intervals.static RegionBSPTree1D
full()
Return a newRegionBSPTree1D
instance containing the entire space.double
Get the size of the boundary of the region.double
getMax()
Get the maximum value on the inside of the region; returnsDouble.POSITIVE_INFINITY
if the region does not have a maximum value andDouble.NEGATIVE_INFINITY
if the region is empty.double
getMin()
Get the minimum value on the inside of the region; returnsDouble.NEGATIVE_INFINITY
if the region does not have a minimum value andDouble.POSITIVE_INFINITY
if the region is empty.private static RegionBSPTree1D
intervalToTree
(Interval interval) Return a tree representing the same region as the given interval.Project a point onto the boundary of the region.split
(Hyperplane<Vector1D> splitter) Split this instance with the given hyperplane.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.Convert the region represented by this tree into a list of separateInterval
s, arranged in order of ascending min value.private void
Compute the min/max intervals for all interior convex regions in the tree and pass the values to the given visitor function.Methods inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree
boundaries, classify, complement, complement, condense, copyNodeProperties, createBoundaryIterable, createBoundaryList, difference, difference, getBoundaries, 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, toString, transform, 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 location.
-
-
Constructor Details
-
RegionBSPTree1D
public RegionBSPTree1D()Create a new, empty region. -
RegionBSPTree1D
public RegionBSPTree1D(boolean full) Create a new region. Iffull
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 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
-
classify
Classify a point location with respect to the region.- Parameters:
x
- the point to classify- Returns:
- the location of the point with respect to the region
- See Also:
-
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:
-
getBoundarySize
public double getBoundarySize()Get the size of the boundary of the region. The size is a value in thed-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 interfaceRegion<Vector1D>
- Overrides:
getBoundarySize
in classAbstractRegionBSPTree<Vector1D,
RegionBSPTree1D.RegionNode1D> - Returns:
- the size of the boundary of the region
-
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<Vector1D>
- Overrides:
project
in classAbstractRegionBSPTree<Vector1D,
RegionBSPTree1D.RegionNode1D> - 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
-
split
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; returnsDouble.NEGATIVE_INFINITY
if the region does not have a minimum value andDouble.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; returnsDouble.POSITIVE_INFINITY
if the region does not have a maximum value andDouble.NEGATIVE_INFINITY
if the region is empty.- Returns:
- the maximum value on the inside of the region
-
toIntervals
Convert the region represented by this tree into a list of separateInterval
s, arranged in order of ascending min value.- Returns:
- list of
Interval
s 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 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
-
visitInsideIntervals
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
-
createNode
Create a new node for this tree.- Specified by:
createNode
in classAbstractBSPTree<Vector1D,
RegionBSPTree1D.RegionNode1D> - Returns:
- a new node for this tree
-
computeRegionSizeProperties
Compute the size-related properties of the region.- Specified by:
computeRegionSizeProperties
in classAbstractRegionBSPTree<Vector1D,
RegionBSPTree1D.RegionNode1D> - Returns:
- object containing size properties for the region
-
swapsInsideOutside
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 classAbstractBSPTree<Vector1D,
RegionBSPTree1D.RegionNode1D> - Parameters:
transform
- transform to check- Returns:
- true if the given transform swaps the interior and exterior of the region
-
full
Return a newRegionBSPTree1D
instance containing the entire space.- Returns:
- a new
RegionBSPTree1D
instance containing the entire space
-
empty
Return a new, emptyRegionBSPTree1D
instance.- Returns:
- a new, empty
RegionBSPTree1D
instance
-
from
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 intervalmore
- 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
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
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
-