Class Lines3D
java.lang.Object
org.apache.commons.geometry.euclidean.threed.line.Lines3D
Class containing factory methods for constructing
Line3D
and LineSubset3D
instances.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Line3D
fromPointAndDirection
(Vector3D pt, Vector3D dir, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Create a new line instance from a point and a direction.static Line3D
fromPoints
(Vector3D p1, Vector3D p2, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Create a new line instance from two points that lie on the line.static Ray3D
rayFromLocation
(Line3D line, double startLocation) Construct a ray starting at the given 1D location online
and continuing in the direction of the line to infinity.static Ray3D
rayFromPoint
(Line3D line, Vector3D startPoint) Construct a ray starting at the given point and continuing to infinity in the direction ofline
.static Ray3D
rayFromPointAndDirection
(Vector3D startPoint, Vector3D direction, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a ray from a start point and a direction.static ReverseRay3D
reverseRayFromLocation
(Line3D line, double endLocation) Construct a reverse ray starting at infinity and continuing in the direction ofline
to the given 1D end location.static ReverseRay3D
reverseRayFromPoint
(Line3D line, Vector3D endPoint) Construct a reverse ray starting at infinity and continuing in the direction ofline
to the given end point.static ReverseRay3D
reverseRayFromPointAndDirection
(Vector3D endPoint, Vector3D lineDirection, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a reverse ray from an end point and a line direction.static Segment3D
segmentFromLocations
(Line3D line, double a, double b) Construct a new line segment from a pair of 1D locations on a line.static Segment3D
segmentFromPoints
(Line3D line, Vector3D a, Vector3D b) Construct a new line segment from a line and a pair of points.static Segment3D
segmentFromPoints
(Vector3D startPoint, Vector3D endPoint, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new line segment from two points.static LineConvexSubset3D
Create aLineConvexSubset3D
spanning the entire line.static LineConvexSubset3D
subsetFromInterval
(Line3D line, double a, double b) Create a line convex subset from a line and a 1D interval on the line.static LineConvexSubset3D
subsetFromInterval
(Line3D line, Interval interval) Create a line convex subset from a line and a 1D interval on the line.static LineConvexSubset3D
subsetFromInterval
(Line3D line, Vector1D a, Vector1D b) Create a line convex subset from a line and a 1D interval on the line.
-
Constructor Details
-
Lines3D
private Lines3D()Utility class; no instantiation.
-
-
Method Details
-
fromPoints
public static Line3D fromPoints(Vector3D p1, Vector3D p2, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Create a new line instance from two points that lie on the line. The line direction points from the first point to the second point.- Parameters:
p1
- first point on the linep2
- second point on the lineprecision
- floating point precision context- Returns:
- a new line instance that contains both of the given point and that has a direction going from the first point to the second point
- Throws:
IllegalArgumentException
- if the points lie too close to create a non-zero direction vector
-
fromPointAndDirection
public static Line3D fromPointAndDirection(Vector3D pt, Vector3D dir, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Create a new line instance from a point and a direction.- Parameters:
pt
- a point lying on the linedir
- the direction of the lineprecision
- floating point precision context- Returns:
- a new line instance that contains the given point and points in the given direction
- Throws:
IllegalArgumentException
- ifdir
has zero length, as evaluated by the given precision context
-
rayFromPointAndDirection
public static Ray3D rayFromPointAndDirection(Vector3D startPoint, Vector3D direction, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a ray from a start point and a direction.- Parameters:
startPoint
- ray start pointdirection
- ray directionprecision
- precision context used for floating point comparisons- Returns:
- a new ray instance with the given start point and direction
- Throws:
IllegalArgumentException
- Ifdirection
has zero length, as evaluated by the given precision context- See Also:
-
rayFromPoint
Construct a ray starting at the given point and continuing to infinity in the direction ofline
. The given point is projected onto the line.- Parameters:
line
- line for the raystartPoint
- start point for the ray- Returns:
- a new ray instance starting at the given point and continuing in the direction of
line
- Throws:
IllegalArgumentException
- if any coordinate instartPoint
is NaN or infinite
-
rayFromLocation
Construct a ray starting at the given 1D location online
and continuing in the direction of the line to infinity.- Parameters:
line
- line for the raystartLocation
- 1D location of the ray start point- Returns:
- a new ray instance starting at the given 1D location and continuing to infinity
along
line
- Throws:
IllegalArgumentException
- ifstartLocation
is NaN or infinite
-
reverseRayFromPointAndDirection
public static ReverseRay3D reverseRayFromPointAndDirection(Vector3D endPoint, Vector3D lineDirection, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a reverse ray from an end point and a line direction.- Parameters:
endPoint
- instance end pointlineDirection
- line directionprecision
- precision context used for floating point comparisons- Returns:
- a new reverse ray with the given end point and line direction
- Throws:
IllegalArgumentException
- IflineDirection
has zero length, as evaluated by the given precision context- See Also:
-
reverseRayFromPoint
Construct a reverse ray starting at infinity and continuing in the direction ofline
to the given end point. The point is projected onto the line.- Parameters:
line
- line for the instanceendPoint
- end point for the instance- Returns:
- a new reverse ray starting at infinity and continuing along the line to
endPoint
- Throws:
IllegalArgumentException
- if any coordinate inendPoint
is NaN or infinite
-
reverseRayFromLocation
Construct a reverse ray starting at infinity and continuing in the direction ofline
to the given 1D end location.- Parameters:
line
- line for the instanceendLocation
- 1D location of the instance end point- Returns:
- a new reverse ray starting infinity and continuing in the direction of
line
to the given 1D end location - Throws:
IllegalArgumentException
- ifendLocation
is NaN or infinite
-
segmentFromPoints
public static Segment3D segmentFromPoints(Vector3D startPoint, Vector3D endPoint, org.apache.commons.numbers.core.Precision.DoubleEquivalence precision) Construct a new line segment from two points. A new line is created for the segment and points in the direction fromstartPoint
toendPoint
.- Parameters:
startPoint
- segment start pointendPoint
- segment end pointprecision
- precision context to use for floating point comparisons- Returns:
- a new line segment instance with the given start and end points
- Throws:
IllegalArgumentException
- If the vector betweenstartPoint
andendPoint
has zero length, as evaluated by the given precision context- See Also:
-
segmentFromPoints
Construct a new line segment from a line and a pair of points. The returned segment represents all points on the line between the projected locations ofa
andb
. The points may be given in any order.- Parameters:
line
- line forming the base of the segmenta
- first pointb
- second point- Returns:
- a new line segment representing the points between the projected locations of
a
andb
on the given line - Throws:
IllegalArgumentException
- if either point contains NaN or infinite coordinate values)
-
segmentFromLocations
Construct a new line segment from a pair of 1D locations on a line. The returned line segment consists of all points between the two locations, regardless of the order the arguments are given.- Parameters:
line
- line forming the base of the segmenta
- first 1D location on the lineb
- second 1D location on the line- Returns:
- a new line segment representing the points between
a
andb
on the given line - Throws:
IllegalArgumentException
- if either of the locations is NaN or infinite
-
span
Create aLineConvexSubset3D
spanning the entire line. In other words, the returned subset is infinite and contains all points on the given line.- Parameters:
line
- the line to span- Returns:
- a convex subset spanning the entire line
-
subsetFromInterval
Create a line convex subset from a line and a 1D interval on the line.- Parameters:
line
- the line containing the subsetinterval
- 1D interval on the line- Returns:
- a line convex subset defined by the given line and interval
-
subsetFromInterval
Create a line convex subset from a line and a 1D interval on the line.- Parameters:
line
- the line containing the subseta
- first 1D location on the lineb
- second 1D location on the line- Returns:
- a line convex subset defined by the given line and interval
-
subsetFromInterval
Create a line convex subset from a line and a 1D interval on the line.- Parameters:
line
- the line containing the subseta
- first 1D point on the line; must not be nullb
- second 1D point on the line; must not be null- Returns:
- a line convex subset defined by the given line and interval
-