Class LineSubset
- java.lang.Object
-
- org.apache.commons.geometry.euclidean.twod.LineSubset
-
- All Implemented Interfaces:
Embedding<Vector2D,Vector1D>,HyperplaneSubset<Vector2D>,Splittable<Vector2D,HyperplaneSubset<Vector2D>>,RegionEmbedding<Vector2D,Vector1D>,Sized
- Direct Known Subclasses:
EmbeddedTreeLineSubset,LineConvexSubset
public abstract class LineSubset extends java.lang.Object implements HyperplaneSubset<Vector2D>, RegionEmbedding<Vector2D,Vector1D>
Class representing a subset of points on a line in 2D Euclidean space. For example, line segments and rays are line subsets. Line subsets may be finite or infinite.
-
-
Constructor Summary
Constructors Constructor Description LineSubset(Line line)Construct a new instance based on the given line.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description RegionLocationclassify(Vector2D pt)Classify a point with respect to the subset region.(package private) abstract RegionLocationclassifyAbscissa(double abscissa)Classify the given line abscissa value with respect to the subspace region.(package private) <T extends LineSubset>
Split<T>createSplitResult(Line splitter, T low, T high)Create a split result for the given splitter line, given the low and high split portion of this instance.abstract Bounds2DgetBounds()Get aBounds2Dobject defining an axis-aligned bounding box containing all vertices for this subset.LinegetHyperplane()Get the hyperplane containing this instance.LinegetLine()Get the line containing this subset.(package private) <T extends LineSubset>
Split<T>getNonIntersectingSplitResult(Line splitter, T subset)Get a split result for cases where no intersection exists between the splitting line and the line underlying the given line subset.org.apache.commons.numbers.core.Precision.DoubleEquivalencegetPrecision()Return the object used to perform floating point comparisons, which is the same object used by the underlyingLine).abstract HyperplaneBoundedRegion<Vector1D>getSubspaceRegion()Get the embedded subspace region.Vector2Dintersection(Line inputLine)Get the unique intersection of this subset with the given line.Vector2Dintersection(LineSubset subset)Get the unique intersection of this instance with the given line subset.(package private) booleansplitterPlusIsPositiveFacing(Line splitterLine)Return true if the plus side of the given splitter line is facing in the positive direction of this line.abstract java.util.List<LineConvexSubset>toConvex()Convert this instance into a list of convex child subsets representing the same region.Vector2DtoSpace(Vector1D pt)Transform a subspace point into a space point.Vector1DtoSubspace(Vector2D pt)Transform a space point into a subspace point.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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
closest, contains, getCentroid, isEmpty, isFull, transform
-
Methods inherited from interface org.apache.commons.geometry.core.Sized
getSize, isFinite, isInfinite
-
Methods inherited from interface org.apache.commons.geometry.core.partitioning.Splittable
split
-
-
-
-
Field Detail
-
line
private final Line line
The line containing this instance.
-
-
Constructor Detail
-
LineSubset
LineSubset(Line line)
Construct a new instance based on the given line.- Parameters:
line- line forming the base of the instance
-
-
Method Detail
-
getLine
public Line getLine()
Get the line containing this subset. This method is an alias forgetHyperplane().- Returns:
- the line containing this subset
- See Also:
getHyperplane()
-
getHyperplane
public Line getHyperplane()
Get the hyperplane containing this instance.- Specified by:
getHyperplanein interfaceHyperplaneSubset<Vector2D>- Returns:
- the hyperplane containing this instance
-
toSubspace
public Vector1D toSubspace(Vector2D pt)
Transform a space point into a subspace point.- Specified by:
toSubspacein interfaceEmbedding<Vector2D,Vector1D>- Parameters:
pt- n-dimension point of the space- Returns:
- lower-dimension point of the subspace corresponding to the specified space point
- See Also:
Embedding.toSpace(S)
-
getBounds
public abstract Bounds2D getBounds()
Get aBounds2Dobject 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.- Returns:
- the bounding box for this instance or null if no valid bounds could be determined
-
getSubspaceRegion
public abstract HyperplaneBoundedRegion<Vector1D> getSubspaceRegion()
Get the embedded subspace region.- Specified by:
getSubspaceRegionin interfaceRegionEmbedding<Vector2D,Vector1D>- Returns:
- the embedded subspace region
-
toSpace
public Vector2D toSpace(Vector1D pt)
Transform a subspace point into a space point.- Specified by:
toSpacein interfaceEmbedding<Vector2D,Vector1D>- Parameters:
pt- lower-dimension point of the subspace- Returns:
- n-dimension point of the space corresponding to the specified subspace point
- See Also:
Embedding.toSubspace(Point)
-
toConvex
public abstract java.util.List<LineConvexSubset> 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:
toConvexin interfaceHyperplaneSubset<Vector2D>- Returns:
- a list of hyperplane convex subsets representing the same subspace region as this instance
-
classify
public RegionLocation classify(Vector2D pt)
Classify a point with respect to the subset region. The point is classified as follows:- Specified by:
classifyin interfaceHyperplaneSubset<Vector2D>- Parameters:
pt- the point to classify- Returns:
- classification of the point with respect to the hyperplane and subspace region
-
intersection
public Vector2D intersection(Line inputLine)
Get the unique intersection of this subset with the given line. Null is returned if no unique intersection point exists (ie, the lines are parallel or coincident) or the line does not intersect this instance.- Parameters:
inputLine- line to intersect with this line subset- Returns:
- the unique intersection point between the line and this line subset or null if no such point exists.
- See Also:
Line.intersection(Line)
-
intersection
public Vector2D intersection(LineSubset subset)
Get the unique intersection of this instance with the given line subset. Null is returned if the lines containing the line subsets do not have a unique intersection point (ie, they are parallel or coincident) or the intersection point is unique but is not contained in both line subsets.- Parameters:
subset- line subset to intersect with- Returns:
- the unique intersection point between this line subset and the argument or null if no such point exists.
- See Also:
Line.intersection(Line)
-
getPrecision
public org.apache.commons.numbers.core.Precision.DoubleEquivalence getPrecision()
Return the object used to perform floating point comparisons, which is the same object used by the underlyingLine).- Returns:
- precision object used to perform floating point comparisons.
-
classifyAbscissa
abstract RegionLocation classifyAbscissa(double abscissa)
Classify the given line abscissa value with respect to the subspace region.- Parameters:
abscissa- the abscissa value to classify- Returns:
- the region location of the line abscissa value
-
getNonIntersectingSplitResult
<T extends LineSubset> Split<T> getNonIntersectingSplitResult(Line splitter, T subset)
Get a split result for cases where no intersection exists between the splitting line and the line underlying the given line subset. This occurs when the two lines are parallel or coincident.- Type Parameters:
T- Line subset type- Parameters:
splitter- splitting linesubset- line subset instance being split- Returns:
- return result of the non-intersecting split operation
-
splitterPlusIsPositiveFacing
boolean splitterPlusIsPositiveFacing(Line splitterLine)
Return true if the plus side of the given splitter line is facing in the positive direction of this line.- Parameters:
splitterLine- line splitting this instance- Returns:
- true if the plus side of the given line is facing in the positive direction of this line
-
createSplitResult
<T extends LineSubset> Split<T> createSplitResult(Line splitter, T low, T high)
Create a split result for the given splitter line, given the low and high split portion of this instance. The arguments are assigned to the split result's minus and plus properties based on the relative orientation of the splitter line.- Type Parameters:
T- Line subset type- Parameters:
splitter- splitter linelow- portion of the split result closest to negative infinity on this linehigh- portion of th split result closest to positive infinity on this line- Returns:
- a split result for the given splitter line.
-
-