Class Lines3D


  • public final class Lines3D
    extends java.lang.Object
    Class containing factory methods for constructing Line3D and LineSubset3D instances.
    • Constructor Detail

      • Lines3D

        private Lines3D()
        Utility class; no instantiation.
    • Method Detail

      • 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 line
        p2 - second point on the line
        precision - 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:
        java.lang.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 line
        dir - the direction of the line
        precision - floating point precision context
        Returns:
        a new line instance that contains the given point and points in the given direction
        Throws:
        java.lang.IllegalArgumentException - if dir 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 point
        direction - ray direction
        precision - precision context used for floating point comparisons
        Returns:
        a new ray instance with the given start point and direction
        Throws:
        java.lang.IllegalArgumentException - If direction has zero length, as evaluated by the given precision context
        See Also:
        fromPointAndDirection(Vector3D, Vector3D, Precision.DoubleEquivalence)
      • rayFromPoint

        public static Ray3D rayFromPoint​(Line3D line,
                                         Vector3D startPoint)
        Construct a ray starting at the given point and continuing to infinity in the direction of line. The given point is projected onto the line.
        Parameters:
        line - line for the ray
        startPoint - start point for the ray
        Returns:
        a new ray instance starting at the given point and continuing in the direction of line
        Throws:
        java.lang.IllegalArgumentException - if any coordinate in startPoint is NaN or infinite
      • rayFromLocation

        public static Ray3D rayFromLocation​(Line3D line,
                                            double startLocation)
        Construct a ray starting at the given 1D location on line and continuing in the direction of the line to infinity.
        Parameters:
        line - line for the ray
        startLocation - 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:
        java.lang.IllegalArgumentException - if startLocation 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 point
        lineDirection - line direction
        precision - precision context used for floating point comparisons
        Returns:
        a new reverse ray with the given end point and line direction
        Throws:
        java.lang.IllegalArgumentException - If lineDirection has zero length, as evaluated by the given precision context
        See Also:
        fromPointAndDirection(Vector3D, Vector3D, Precision.DoubleEquivalence)
      • reverseRayFromPoint

        public static ReverseRay3D reverseRayFromPoint​(Line3D line,
                                                       Vector3D endPoint)
        Construct a reverse ray starting at infinity and continuing in the direction of line to the given end point. The point is projected onto the line.
        Parameters:
        line - line for the instance
        endPoint - end point for the instance
        Returns:
        a new reverse ray starting at infinity and continuing along the line to endPoint
        Throws:
        java.lang.IllegalArgumentException - if any coordinate in endPoint is NaN or infinite
      • reverseRayFromLocation

        public static ReverseRay3D reverseRayFromLocation​(Line3D line,
                                                          double endLocation)
        Construct a reverse ray starting at infinity and continuing in the direction of line to the given 1D end location.
        Parameters:
        line - line for the instance
        endLocation - 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:
        java.lang.IllegalArgumentException - if endLocation 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 from startPoint to endPoint.
        Parameters:
        startPoint - segment start point
        endPoint - segment end point
        precision - precision context to use for floating point comparisons
        Returns:
        a new line segment instance with the given start and end points
        Throws:
        java.lang.IllegalArgumentException - If the vector between startPoint and endPoint has zero length, as evaluated by the given precision context
        See Also:
        fromPoints(Vector3D, Vector3D, Precision.DoubleEquivalence)
      • segmentFromPoints

        public static Segment3D segmentFromPoints​(Line3D line,
                                                  Vector3D a,
                                                  Vector3D b)
        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 of a and b. The points may be given in any order.
        Parameters:
        line - line forming the base of the segment
        a - first point
        b - second point
        Returns:
        a new line segment representing the points between the projected locations of a and b on the given line
        Throws:
        java.lang.IllegalArgumentException - if either point contains NaN or infinite coordinate values)
      • segmentFromLocations

        public static Segment3D segmentFromLocations​(Line3D line,
                                                     double a,
                                                     double b)
        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 segment
        a - first 1D location on the line
        b - second 1D location on the line
        Returns:
        a new line segment representing the points between a and b on the given line
        Throws:
        java.lang.IllegalArgumentException - if either of the locations is NaN or infinite
      • span

        public static LineConvexSubset3D span​(Line3D line)
        Create a LineConvexSubset3D 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

        public static LineConvexSubset3D subsetFromInterval​(Line3D line,
                                                            Interval interval)
        Create a line convex subset from a line and a 1D interval on the line.
        Parameters:
        line - the line containing the subset
        interval - 1D interval on the line
        Returns:
        a line convex subset defined by the given line and interval
      • subsetFromInterval

        public static LineConvexSubset3D subsetFromInterval​(Line3D line,
                                                            double a,
                                                            double b)
        Create a line convex subset from a line and a 1D interval on the line.
        Parameters:
        line - the line containing the subset
        a - first 1D location on the line
        b - second 1D location on the line
        Returns:
        a line convex subset defined by the given line and interval
      • subsetFromInterval

        public static LineConvexSubset3D subsetFromInterval​(Line3D line,
                                                            Vector1D a,
                                                            Vector1D b)
        Create a line convex subset from a line and a 1D interval on the line.
        Parameters:
        line - the line containing the subset
        a - first 1D point on the line; must not be null
        b - second 1D point on the line; must not be null
        Returns:
        a line convex subset defined by the given line and interval