Class BoundarySourceLinecaster2D
- java.lang.Object
-
- org.apache.commons.geometry.euclidean.twod.BoundarySourceLinecaster2D
-
- All Implemented Interfaces:
Linecastable2D
final class BoundarySourceLinecaster2D extends java.lang.Object implements Linecastable2D
Class that performs linecast operations against arbitraryBoundarySource2D
instances. This class performs a brute-force computation of the intersections of the line or line subset against all boundaries. Some data structures may support more efficient algorithms and should therefore prefer those instead.
-
-
Field Summary
Fields Modifier and Type Field Description private BoundarySource2D
boundarySrc
The boundary source instance providing boundaries for the linecast operation.
-
Constructor Summary
Constructors Constructor Description BoundarySourceLinecaster2D(BoundarySource2D boundarySrc)
Construct a new instance for linecasting against the given boundary source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private LinecastPoint2D
computeIntersection(LineConvexSubset boundary, LineConvexSubset subset)
Compute the intersection between a boundary line subset and linecast intersecting line subset.private java.util.stream.Stream<LinecastPoint2D>
getIntersectionStream(LineConvexSubset subset)
Return a stream containing intersections between the boundary source and the given line subset.java.util.List<LinecastPoint2D>
linecast(LineConvexSubset subset)
Intersect the given line subset against the boundaries in this instance, returning a list of all intersections in order of increasing position along the line.LinecastPoint2D
linecastFirst(LineConvexSubset subset)
Intersect the given line subset against the boundaries in this instance, returning the first intersection found when traveling in the direction of the line subset from its start location.-
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.euclidean.twod.Linecastable2D
linecast, linecastFirst
-
-
-
-
Field Detail
-
boundarySrc
private final BoundarySource2D boundarySrc
The boundary source instance providing boundaries for the linecast operation.
-
-
Constructor Detail
-
BoundarySourceLinecaster2D
BoundarySourceLinecaster2D(BoundarySource2D boundarySrc)
Construct a new instance for linecasting against the given boundary source.- Parameters:
boundarySrc
- boundary source to linecast against.
-
-
Method Detail
-
linecast
public java.util.List<LinecastPoint2D> linecast(LineConvexSubset subset)
Intersect the given line subset against the boundaries in this instance, returning a list of all intersections in order of increasing position along the line. An empty list is returned if no intersections are discovered.- Specified by:
linecast
in interfaceLinecastable2D
- Parameters:
subset
- line subset to intersect- Returns:
- a list of computed intersections in order of increasing position along the line
-
linecastFirst
public LinecastPoint2D linecastFirst(LineConvexSubset subset)
Intersect the given line subset against the boundaries in this instance, returning the first intersection found when traveling in the direction of the line subset from its start location.- Specified by:
linecastFirst
in interfaceLinecastable2D
- Parameters:
subset
- line subset to intersect- Returns:
- the first intersection found or null if no intersection is found
-
getIntersectionStream
private java.util.stream.Stream<LinecastPoint2D> getIntersectionStream(LineConvexSubset subset)
Return a stream containing intersections between the boundary source and the given line subset.- Parameters:
subset
- line subset to intersect- Returns:
- a stream containing linecast intersections
-
computeIntersection
private LinecastPoint2D computeIntersection(LineConvexSubset boundary, LineConvexSubset subset)
Compute the intersection between a boundary line subset and linecast intersecting line subset. Null is returned if no intersection is discovered.- Parameters:
boundary
- boundary from the boundary sourcesubset
- line subset to intersect with- Returns:
- the linecast intersection between the two arguments or null if there is no such intersection
-
-