Class EmbeddedTreeLineSubset
- All Implemented Interfaces:
Embedding<Vector2D,
,Vector1D> HyperplaneSubset<Vector2D>
,Splittable<Vector2D,
,HyperplaneSubset<Vector2D>> RegionEmbedding<Vector2D,
,Vector1D> Sized
RegionBSPTree1D
.
This class can represent convex, non-convex, finite, infinite, and empty regions.
This class is mutable and not thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final RegionBSPTree1D
The 1D region representing the area on the line. -
Constructor Summary
ConstructorsConstructorDescriptionEmbeddedTreeLineSubset
(Line line) Construct a new, empty subset for the given line.EmbeddedTreeLineSubset
(Line line, boolean full) Construct a new subset for the given line.EmbeddedTreeLineSubset
(Line line, RegionBSPTree1D region) Construct a new instance from its defining line and subspace region. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(EmbeddedTreeLineSubset subset) Add the region represented by the given line subset to this instance.void
add
(LineConvexSubset subset) Add a line subset to this instance.(package private) RegionLocation
classifyAbscissa
(double abscissa) Classify the given line abscissa value with respect to the subspace region.Return the closest point to the argument that is contained in the subset (ie, not classified asoutside
), or null if no such point exists.Get aBounds2D
object defining an axis-aligned bounding box containing all vertices for this subset.Get the centroid, or geometric center, of the hyperplane subset or null if no centroid exists or one exists but is not unique.double
getSize()
Get the size of the instance.Get the embedded subspace region.boolean
isEmpty()
Return true if this instance does not contain any points.boolean
isFull()
Return true if this instance contains all points in the hyperplane.split
(Hyperplane<Vector2D> splitter) Split this instance with the given hyperplane.toConvex()
Convert this instance into a list of convex child subsets representing the same region.toString()
Return a new hyperplane subset resulting from the application of the given transform.Methods inherited from class org.apache.commons.geometry.euclidean.twod.LineSubset
classify, createSplitResult, getHyperplane, getLine, getNonIntersectingSplitResult, getPrecision, intersection, intersection, splitterPlusIsPositiveFacing, toSpace, toSubspace
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.Embedding
toSpace, toSubspace
Methods inherited from interface org.apache.commons.geometry.core.partitioning.HyperplaneSubset
contains
Methods inherited from interface org.apache.commons.geometry.core.Sized
isFinite, isInfinite
-
Field Details
-
region
The 1D region representing the area on the line.
-
-
Constructor Details
-
EmbeddedTreeLineSubset
Construct a new, empty subset for the given line.- Parameters:
line
- line defining the subset
-
EmbeddedTreeLineSubset
Construct a new subset for the given line. Iffull
is true, then the subset will cover the entire line; otherwise, it will be empty.- Parameters:
line
- line defining the subsetfull
- if true, the subset will cover the entire space; otherwise it will be empty
-
EmbeddedTreeLineSubset
Construct a new instance from its defining line and subspace region. The give BSP tree is used directly by this instance; it is not copied.- Parameters:
line
- line defining the subsetregion
- subspace region for the instance
-
-
Method Details
-
isFull
public boolean isFull()Return true if this instance contains all points in the hyperplane.- Returns:
- true if this instance contains all points in the hyperplane
-
isEmpty
public boolean isEmpty()Return true if this instance does not contain any points.- Returns:
- true if this instance does not contain any points
-
getSize
public double getSize()Get the size of the instance.- Returns:
- the size of the instance
-
getCentroid
Get the centroid, or geometric center, of the hyperplane subset or null if no centroid exists or one exists but is not unique. A centroid will not exist for empty or infinite subsets.The centroid of a geometric object is defined as the mean position of all points in the object, including interior points, vertices, and other points lying on the boundary. If a physical object has a uniform density, then its center of mass is the same as its geometric centroid.
- Returns:
- the centroid of the hyperplane subset or null if no unique centroid exists
- See Also:
-
getBounds
Get aBounds2D
object defining an axis-aligned bounding box containing all vertices for this subset. Null is returned if the subset is infinite or does not contain any vertices.- Specified by:
getBounds
in classLineSubset
- Returns:
- the bounding box for this instance or null if no valid bounds could be determined
-
closest
Return the closest point to the argument that is contained in the subset (ie, not classified asoutside
), or null if no such point exists.- Parameters:
pt
- the reference point- Returns:
- the closest point to the reference point that is contained in the subset, or null if no such point exists
-
transform
Return a new hyperplane subset resulting from the application of the given transform. The current instance is not modified.- Parameters:
transform
- the transform instance to apply- Returns:
- new transformed hyperplane subset
-
toConvex
Convert this instance into a list of convex child subsets representing the same region. Implementations are not required to return an optimal convex subdivision of the current instance. They are free to return whatever subdivision is readily available.- Specified by:
toConvex
in interfaceHyperplaneSubset<Vector2D>
- Specified by:
toConvex
in classLineSubset
- Returns:
- a list of hyperplane convex subsets representing the same subspace region as this instance
-
getSubspaceRegion
Get the embedded subspace region.- Specified by:
getSubspaceRegion
in interfaceRegionEmbedding<Vector2D,
Vector1D> - Specified by:
getSubspaceRegion
in classLineSubset
- Returns:
- the embedded subspace region
-
split
Split this instance with the given hyperplane.In all cases, the current instance is not modified. However, In order to avoid unnecessary copying, this method will use the current instance as the split value when the instance lies entirely on the plus or minus side of the splitter. For example, if this instance lies entirely on the minus side of the splitter, the subplane returned by
Split.getMinus()
will be this instance. Similarly,Split.getPlus()
will return the current instance if it lies entirely on the plus side. Callers need to make special note of this, since this class is mutable.- Parameters:
splitter
- the hyperplane to split this object with.- Returns:
- result of the split operation
-
add
Add a line subset to this instance.- Parameters:
subset
- the line subset to add- Throws:
IllegalArgumentException
- if the given line subset is not from a line equivalent to this instance
-
add
Add the region represented by the given line subset to this instance. The argument is not modified.- Parameters:
subset
- line subset to add- Throws:
IllegalArgumentException
- if the given line subset is not from a line equivalent to this instance
-
toString
-
classifyAbscissa
Classify the given line abscissa value with respect to the subspace region.- Specified by:
classifyAbscissa
in classLineSubset
- Parameters:
abscissa
- the abscissa value to classify- Returns:
- the region location of the line abscissa value
-