Class PolyLine3d

    • Constructor Detail

      • PolyLine3d

        public PolyLine3d​(Point3d point1,
                          Point3d point2,
                          Point3d... otherPoints)
                   throws NullPointerException,
                          DrawRuntimeException
        Construct a new PolyLine3d from an array of Point3d.
        Parameters:
        point1 - Point3d; starting point of the PolyLine3d
        point2 - Point3d; second point of the PolyLine3d
        otherPoints - Point3d...; additional points of the PolyLine3d
        Throws:
        NullPointerException - when iterator is null
        DrawRuntimeException - when the provided points do not constitute a valid line (too few points or identical adjacent points)
      • PolyLine3d

        public PolyLine3d​(Iterator<Point3d> iterator)
                   throws NullPointerException,
                          DrawException
        Construct a new Line3d and initialize its length indexed line, bounds, centroid and length.
        Parameters:
        iterator - Iterator<Point3d>; iterator that will provide all points that constitute the new Line3d
        Throws:
        NullPointerException - when iterator is null
        DrawException - when the iterator provides too few points, or some adjacent identical points)
      • PolyLine3d

        public PolyLine3d​(List<Point3d> pointList)
                   throws DrawRuntimeException
        Construct a new Line3d from a List<Point3d>.
        Parameters:
        pointList - List<Point3d>; the list of points to construct this Line3d from.
        Throws:
        DrawRuntimeException - when the provided points do not constitute a valid line (too few points or identical adjacent points)
    • Method Detail

      • size

        public int size()
        Retrieve the number of points that make up the object.
        Specified by:
        size in interface Drawable<Point3d,​Space3d>
        Returns:
        int; the number of points that make up the object
      • lengthAtIndex

        public final double lengthAtIndex​(int index)
        Access the internal lengthIndexedLine. Return the cumulative length up to point index of this line
        Specified by:
        lengthAtIndex in interface PolyLine<PolyLine3d,​Point3d,​Space3d,​OrientedPoint3d>
        Parameters:
        index - int; the index
        Returns:
        double; the cumulative length of this line up to point index
      • getLength

        public final double getLength()
        Return the length of this line. This is NOT the number of points; it is the sum of the lengths of the segments.
        Specified by:
        getLength in interface PolyLine<PolyLine3d,​Point3d,​Space3d,​OrientedPoint3d>
        Returns:
        double; the length of this line
      • getPoints

        public Iterator<Point3d> getPoints()
        Retrieve, or generate all points that make up the object.
        Specified by:
        getPoints in interface Drawable<Point3d,​Space3d>
        Returns:
        Iterable<Point2d>; an iterator that generates all points that make up the object
      • getBounds

        public Bounds3d getBounds()
        Retrieve the bounding box of the object.
        Specified by:
        getBounds in interface Drawable3d
        Returns:
        Bounds3d; the bounding box of the object
      • noiseFilteredLine

        public final PolyLine3d noiseFilteredLine​(double noiseLevel)
        Construct a new Line3d that is equal to this line except for segments that are shorter than the noiseLevel. The result is guaranteed to start with the first point of this line and end with the last point of this line.
        Parameters:
        noiseLevel - double; the minimum segment length that is not removed
        Returns:
        Line3d; the filtered line
      • concatenate

        public static PolyLine3d concatenate​(PolyLine3d... lines)
                                      throws DrawException
        Concatenate several Line3d instances.
        Parameters:
        lines - PolyLine3d...; Line3d... one or more Line3d. The last point of the first <strong>must</strong> match the first of the second, etc.
        Returns:
        Line3d
        Throws:
        DrawException - if zero lines are given, or when there is a gap between consecutive lines
      • concatenate

        public static PolyLine3d concatenate​(double tolerance,
                                             PolyLine3d line1,
                                             PolyLine3d line2)
                                      throws DrawException
        Concatenate two Line3d instances. This method is separate for efficiency reasons.
        Parameters:
        tolerance - double; the tolerance between the end point of a line and the first point of the next line
        line1 - PolyLine3d; first line
        line2 - PolyLine3d; second line
        Returns:
        Line3d; the concatenation of the two lines
        Throws:
        DrawException - if zero lines are given, or when there is a gap between consecutive lines
      • concatenate

        public static PolyLine3d concatenate​(double tolerance,
                                             PolyLine3d... lines)
                                      throws DrawException
        Concatenate several Line3d instances.
        Parameters:
        tolerance - double; the tolerance between the end point of a line and the first point of the next line
        lines - PolyLine3d...; Line3d... one or more Line3d. The last point of the first <strong>must</strong> match the first of the second, etc.
        Returns:
        Line3d; the concatenation of the lines
        Throws:
        DrawException - if zero lines are given, or when there is a gap between consecutive lines
      • project

        public PolyLine2d project()
                           throws DrawRuntimeException
        Project the object onto the z=0 plane.
        Specified by:
        project in interface Drawable3d
        Returns:
        Drawable2d; the projected object
        Throws:
        DrawRuntimeException - when projecting onto the z=0 plane results in an invalid object. E.g. a Line3d that consists of points that all have the exact same x and y coordinates cannot be a line after projecting on the z=0 plane.
      • createAndCleanLine3d

        public static PolyLine3d createAndCleanLine3d​(Point3d... points)
                                               throws DrawException
        Create a new Line3d, filtering out repeating successive points.
        Parameters:
        points - Point3d...; the coordinates of the line as Point3d
        Returns:
        the line
        Throws:
        DrawException - when number of points < 2
      • createAndCleanLine3d

        public static PolyLine3d createAndCleanLine3d​(List<Point3d> pointList)
                                               throws DrawException
        Create an Line3d, while filtering out repeating successive points.
        Parameters:
        pointList - List<Point3d>; list of the coordinates of the line as Point3d; any duplicate points in this list are removed (this method may modify the provided list)
        Returns:
        Line3d; the line
        Throws:
        DrawException - when number of non-equal points < 2
      • getLocationExtended

        public final OrientedPoint3d getLocationExtended​(double position)
        Get the location at a position on the line, with its direction. Position can be below 0 or more than the line length. In that case, the position will be extrapolated in the direction of the line at its start or end.
        Specified by:
        getLocationExtended in interface PolyLine<PolyLine3d,​Point3d,​Space3d,​OrientedPoint3d>
        Parameters:
        position - double; the position on the line for which to calculate the point on, before, or after the line
        Returns:
        OP; an oriented point
      • getLocation

        public final OrientedPoint3d getLocation​(double position)
                                          throws DrawException
        Get the location at a position on the line, with its direction. Position should be between 0.0 and line length.
        Specified by:
        getLocation in interface PolyLine<PolyLine3d,​Point3d,​Space3d,​OrientedPoint3d>
        Parameters:
        position - double; the position on the line for which to calculate the point on the line
        Returns:
        OP; an oriented point
        Throws:
        DrawException - when position less than 0.0 or more than line length.
      • extract

        public PolyLine3d extract​(double start,
                                  double end)
                           throws DrawException
        Create a new L that covers a sub-section of this L.
        Specified by:
        extract in interface PolyLine<PolyLine3d,​Point3d,​Space3d,​OrientedPoint3d>
        Parameters:
        start - double; length along this Line3d where the sub-section starts, valid range [0..end)
        end - double; length along this Line3d where the sub-section ends, valid range (start..length (length is the length of this L)
        Returns:
        L; the selected sub-section
        Throws:
        DrawException - when start >= end, or start < 0, or end > length
      • truncate

        public PolyLine3d truncate​(double position)
                            throws DrawException
        Truncate this Line at the given length (less than the length of the line, and larger than zero) and return a new line.
        Specified by:
        truncate in interface PolyLine<PolyLine3d,​Point3d,​Space3d,​OrientedPoint3d>
        Parameters:
        position - double; the position along the line where to truncate the line
        Returns:
        L; a new Line that follows this line, but ends at the position where line.getLength() == lengthSI
        Throws:
        DrawException - when position less than 0.0 or more than line length.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object