Package org.djutils.draw.line
Class PolyLine2d
java.lang.Object
org.djutils.draw.line.PolyLine2d
- All Implemented Interfaces:
Serializable
,Drawable<Point2d>
,Drawable2d
,PolyLine<PolyLine2d,
,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> Project<Point2d>
- Direct Known Subclasses:
Polygon2d
public class PolyLine2d
extends Object
implements Drawable2d, PolyLine<PolyLine2d,Point2d,Ray2d,DirectedPoint2d,LineSegment2d>
Implementation of PolyLine for 2D space.
Copyright (c) 2020-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.
- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.djutils.draw.line.PolyLine
PolyLine.TransitionFunction
-
Field Summary
Fields inherited from interface org.djutils.draw.line.PolyLine
DEFAULT_CIRCLE_PRECISION, DEFAULT_OFFSET_FILTER_RATIO, DEFAULT_OFFSET_MAXIMUM_FILTER_VALUE, DEFAULT_OFFSET_MINIMUM_FILTER_VALUE, DEFAULT_OFFSET_PRECISION
-
Constructor Summary
ConstructorDescriptionPolyLine2d
(boolean copyNeeded, double[] x, double[] y) Construct a new PolyLine2d from an array of double x values and an array of double y values.PolyLine2d
(boolean filterDuplicates, List<Point2d> pointList) Create a new PolyLine2d, optionally filtering out repeating successive points.PolyLine2d
(boolean filterDuplicates, Point2d... points) Create a new PolyLine2d, optionally filtering out repeating successive points.PolyLine2d
(double[] x, double[] y) Construct a new PolyLine2d from an array of x-values and an array of y-values.PolyLine2d
(double x, double y, double heading) Construct a degenerate PolyLine2d (consisting of only one point).PolyLine2d
(Path2D path) Construct a new PolyLine2d from a Path2D.PolyLine2d
(Iterator<Point2d> iterator) Construct a new PolyLine2d from an iterator that yields Point2d objects.PolyLine2d
(List<Point2d> pointList) Construct a new PolyLine2d from a List<Point2d>.PolyLine2d
(PolyLine2d polyLine) Construct a new PolyLine2d from an existing one.PolyLine2d
(DirectedPoint2d directedPoint2d) Construct a degenerate PolyLine2d (consisting of only one point).PolyLine2d
(Point2d[] points) Construct a new PolyLine2d from an array of Point2d.PolyLine2d
(Point2d p, double heading) Construct a degenerate PolyLine2d (consisting of only one point).PolyLine2d
(Point2d point1, Point2d point2, Point2d... otherPoints) Construct a new PolyLine2d from two or more Point2d arguments. -
Method Summary
Modifier and TypeMethodDescriptioncleanPoints
(boolean filter, Iterator<Point2d> iterator) Return an iterator that optionally skips identical successive points.closestPointOnPolyLine
(Point2d point) Project a Point on this PolyLine.static PolyLine2d
concatenate
(double tolerance, PolyLine2d... lines) Concatenate several PolyLine2d instances.static PolyLine2d
concatenate
(double tolerance, PolyLine2d line1, PolyLine2d line2) Concatenate two PolyLine2d instances.static PolyLine2d
concatenate
(PolyLine2d... lines) Concatenate several PolyLine2d instances.boolean
extract
(double start, double end) Create a new PolyLine that covers a sub-section of this PolyLine.final Point2d
get
(int i) Return one of the points of this line.Retrieve the bounding rectangle of the object.double
Return the length of this line.final DirectedPoint2d
getLocation
(double position) Get the location at a position on the line, with its direction.final DirectedPoint2d
getLocationExtended
(double position) Get the location at a position on the line, with its direction.Retrieve, or generate all points that make up the object.getSegment
(int index) Extract one LineSegment of this PolyLine, or Polygon.final double
getX
(int i) Return the x-coordinate of a point of this PolyLine.final double
getY
(int i) Return the y-coordinate of a point of this PolyLine.int
hashCode()
instantiate
(List<Point2d> pointList) Constructor that can be accessed as a method (used to implement default methods in this interface).iteratorToList
(Iterator<Point2d> iterator) Build a list from the Point2d objects that an iterator provides.final double
lengthAtIndex
(int index) Access the internal lengthIndexedLine.protected static double[]
Make an array of double an fill it with the appropriate coordinate of points.final PolyLine2d
noiseFilteredLine
(double noiseLevel) Construct a new PolyLine that is equal to this line except for segments that are shorter than the noiseLevel.offsetLine
(double offset, double circlePrecision, double offsetMinimumFilterValue, double offsetMaximumFilterValue, double offsetFilterRatio, double minimumOffset) Construct an offset line.offsetLine
(double offsetAtStart, double offsetAtEnd, double circlePrecision, double offsetMinimumFilterValue, double offsetMaximumFilterValue, double offsetFilterRatio, double minimumOffset) Construct an offset line.projectOrthogonal
(Point2d point) Project a point onto this object.projectOrthogonalExtended
(Point2d point) Project a point onto this object.final double
Project a point onto this object.double
Project a point onto this object.double
projectRay
(Ray2d ray) Find a location on this PolyLine2d that is a reasonable projection of a Ray on this line.int
size()
Retrieve the number of points that make up the object.toPath2D()
Construct a Path2D from this PolyLine2d.toString()
Produce a string describing the Drawable using default conversion for the (double) coordinate values.Produce a String describing the Drawable.transitionLine
(PolyLine2d endLine, PolyLine.TransitionFunction transition) Make a transition line from this PolyLine to another PolyLine using a user specified function.truncate
(double position) Truncate this PolyLine at the given length (less than the length of the line, and larger than zero) and return a new line.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.draw.Drawable
getPointList, toString, toString
Methods inherited from interface org.djutils.draw.Drawable2d
getDimensions
Methods inherited from interface org.djutils.draw.line.PolyLine
extractFractional, find, getFirst, getLast, getLocationFraction, getLocationFraction, getLocationFractionExtended, offsetLine, offsetLine, reverse
-
Constructor Details
-
PolyLine2d
PolyLine2d(boolean copyNeeded, double[] x, double[] y) throws NullPointerException, DrawRuntimeException Construct a new PolyLine2d from an array of double x values and an array of double y values.- Parameters:
copyNeeded
- boolean; if true; a deep copy of the points array is stored instead of the provided arrayx
- double[]; the x-coordinates of the pointsy
- double[]; the y-coordinates of the points- Throws:
NullPointerException
- when iterator is nullDrawRuntimeException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a degenerate PolyLine2d (consisting of only one point).- Parameters:
x
- double; the x-coordinatey
- double; the y-coordinateheading
- double; the heading in radians- Throws:
DrawRuntimeException
- when x, y, or heading is NaN, or heading is infinite
-
PolyLine2d
Construct a degenerate PolyLine2d (consisting of only one point).- Parameters:
p
- Point2d; the point of the degenerate PolyLine2dheading
- double; the heading in radians- Throws:
NullPointerException
- when p is nullDrawRuntimeException
- when heading is NaN, or heading is infinite
-
PolyLine2d
public PolyLine2d(DirectedPoint2d directedPoint2d) throws NullPointerException, DrawRuntimeException Construct a degenerate PolyLine2d (consisting of only one point).- Parameters:
directedPoint2d
- DirectedPoint2d; point and heading (DirZ) of the degenerate PolyLine2d- Throws:
NullPointerException
- when p is nullDrawRuntimeException
- when heading is NaN or infinite
-
PolyLine2d
Construct a new PolyLine2d from an array of x-values and an array of y-values. This constructor makes a deep copy of the parameters.- Parameters:
x
- double[]; the x-coordinates of the pointsy
- double[]; the y-coordinates of the points- Throws:
NullPointerException
- when iterator is nullDrawRuntimeException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from an array of Point2d.- Parameters:
points
- Point2d[]; the array of points to construct this PolyLine2d from.- Throws:
NullPointerException
- when the array is nullDrawRuntimeException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
public PolyLine2d(Point2d point1, Point2d point2, Point2d... otherPoints) throws NullPointerException, DrawRuntimeException Construct a new PolyLine2d from two or more Point2d arguments.- Parameters:
point1
- Point2d; starting point of the PolyLine2dpoint2
- Point2d; second point of the PolyLine2dotherPoints
- Point2d...; additional points of the PolyLine2d (may be null, or have zero length)- Throws:
NullPointerException
- when point1 is null or point2 is null, or otherPoints contains a null valueDrawRuntimeException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from an iterator that yields Point2d objects.- Parameters:
iterator
- Iterator<Point2d>; iterator that will provide all points that constitute the new PolyLine2d- Throws:
NullPointerException
- when iterator is null, or yields a nullDrawRuntimeException
- when the iterator provides too few points, or some adjacent identical points)
-
PolyLine2d
Construct a new PolyLine2d from a List<Point2d>.- Parameters:
pointList
- List<Point2d>; the list of points to construct the new PolyLine2d from.- Throws:
DrawRuntimeException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)NullPointerException
- when pointList is null, or contains a null value
-
PolyLine2d
Construct a new PolyLine2d from a Path2D.- Parameters:
path
- Path2D; the Path2D to construct this PolyLine2d from.- Throws:
DrawRuntimeException
- when the provided points do not constitute a valid line (too few points or identical adjacent points)NullPointerException
- when path is null
-
PolyLine2d
Create a new PolyLine2d, optionally filtering out repeating successive points.- Parameters:
filterDuplicates
- boolean; if true; filter out successive repeated points; otherwise do not filterpoints
- Point2d...; the coordinates of the line as Point2d- Throws:
DrawRuntimeException
- when number of points < 2
-
PolyLine2d
Create a new PolyLine2d, optionally filtering out repeating successive points.- Parameters:
filterDuplicates
- boolean; if true; filter out successive repeated points; otherwise do not filterpointList
- List<Point2d>; list of the coordinates of the line as Point3d; any duplicate points in this list are removed (this method may modify the provided list)- Throws:
DrawRuntimeException
- when number of non-equal points < 2
-
PolyLine2d
Construct a new PolyLine2d from an existing one. This constructor is primarily intended for use in extending classes.- Parameters:
polyLine
- PolyLine2d; the existing PolyLine2d.
-
-
Method Details
-
makeArray
Make an array of double an fill it with the appropriate coordinate of points.- Parameters:
points
- Point2d[]; array of pointsgetter
- Function<Point2d, Double>; function that obtains the intended coordinate- Returns:
- double[]; array of double filled with the requested coordinate values
-
iteratorToList
Build a list from the Point2d objects that an iterator provides.- Parameters:
iterator
- Iterator<Point2d>; the iterator that will provide the points- Returns:
- List<Point2d>; a list of the points provided by the iterator
-
cleanPoints
Return an iterator that optionally skips identical successive points.- Parameters:
filter
- boolean; if true; filter out identical successive points; if false; do not filteriterator
- Iterator<Point2d>; iterator that generates points, potentially with successive duplicates- Returns:
- Iterator<Point2d>; iterator that skips identical successive points
-
instantiate
public PolyLine2d instantiate(List<Point2d> pointList) throws NullPointerException, DrawRuntimeException Description copied from interface:PolyLine
Constructor that can be accessed as a method (used to implement default methods in this interface).- Specified by:
instantiate
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
pointList
- List<P>; a list of points- Returns:
- L; the new PolyLine
- Throws:
NullPointerException
- when pointList is nullDrawRuntimeException
- when pointList has fewer than two points or contains successive duplicate points
-
size
public int size()Description copied from interface:Drawable
Retrieve the number of points that make up the object. -
get
Description copied from interface:PolyLine
Return one of the points of this line.- Specified by:
get
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
i
- int; the index of the requested point- Returns:
- P; the point at the specified index
- Throws:
IndexOutOfBoundsException
- when index < 0 or index >= size
-
getX
Description copied from interface:PolyLine
Return the x-coordinate of a point of this PolyLine.- Specified by:
getX
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
i
- int; the index of the requested x-coordinate- Returns:
- double; the x-coordinate of the requested point of this PolyLine
- Throws:
IndexOutOfBoundsException
- when index < 0 or index >= size()
-
getY
Description copied from interface:PolyLine
Return the y-coordinate of a point of this PolyLine.- Specified by:
getY
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
i
- int; the index of the requested y-coordinate- Returns:
- double; the y-coordinate of the requested point of this PolyLine
- Throws:
IndexOutOfBoundsException
- when index < 0 or index >= size()
-
getSegment
Description copied from interface:PolyLine
Extract one LineSegment of this PolyLine, or Polygon.- Specified by:
getSegment
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
index
- int; the rank number of the segment; must be in range 0..Size() - 2 for PolyLine, or 0.. Size() - 1 for Polygon.- Returns:
- LS; the LineSegment that connects point index to point index + 1
-
lengthAtIndex
public final double lengthAtIndex(int index) Description copied from interface:PolyLine
Access the internal lengthIndexedLine. Return the cumulative length up to pointindex
of this line- Specified by:
lengthAtIndex
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
index
- int; the index- Returns:
- double; the cumulative length of this line up to point
index
-
getLength
public double getLength()Description copied from interface:PolyLine
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 interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Returns:
- double; the length of this line
-
getPoints
Description copied from interface:Drawable
Retrieve, or generate all points that make up the object. -
getBounds
Description copied from interface:Drawable2d
Retrieve the bounding rectangle of the object.- Specified by:
getBounds
in interfaceDrawable2d
- Returns:
- Bounds2d; the bounding box of the object
-
noiseFilteredLine
Description copied from interface:PolyLine
Construct a new PolyLine 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.- Specified by:
noiseFilteredLine
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
noiseLevel
- double; the minimum segment length that is not removed- Returns:
- PolyLine2d; the filtered line
-
concatenate
Concatenate several PolyLine2d instances.- Parameters:
lines
- PolyLine2d...; One or more PolyLine2d objects. The last point of the first <strong>must</strong> match the first of the second, etc.- Returns:
- PolyLine2d
- Throws:
DrawRuntimeException
- if zero lines are given, or when there is a gap between consecutive lines
-
concatenate
public static PolyLine2d concatenate(double tolerance, PolyLine2d line1, PolyLine2d line2) throws DrawRuntimeException Concatenate two PolyLine2d 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 lineline1
- PolyLine2d; first lineline2
- PolyLine2d; second line- Returns:
- PolyLine2d; the concatenation of the two lines
- Throws:
DrawRuntimeException
- when there is a gap larger than tolerance between the two lines
-
concatenate
public static PolyLine2d concatenate(double tolerance, PolyLine2d... lines) throws DrawRuntimeException Concatenate several PolyLine2d instances.- Parameters:
tolerance
- double; the tolerance between the end point of a line and the first point of the next linelines
- PolyLine2d...; one or more PolyLine2d objects. The last point of the first <strong>must</strong> match the first of the second within the provided tolerance value, etc.- Returns:
- PolyLine2d; the concatenation of the lines
- Throws:
DrawRuntimeException
- if zero lines are given, or when there is a gap larger than tolerance between consecutive lines
-
getLocationExtended
Description copied from interface:PolyLine
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 interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
position
- double; the position on the line for which to calculate the point on, before, or after the line- Returns:
- D; a DirectedPoint at the position on the line, pointing in the direction of the line at that position. If the position is at (or very near) a point on this PolyLine, the direction is either the direction before, or the direction after that point. If the position is before the start point of this PolyLine, the direction is towards the start point. If the position is beyond the end of this PolyLine, the direction is the direction of the last segment of this PolyLine.
-
getLocation
Description copied from interface:PolyLine
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 interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
position
- double; the position on the line for which to calculate the point on the line- Returns:
- D; a DirectedPoint at the position on the line, pointing in the direction of the line at that position. If the position is at (or very near) a point on this PolyLine, the direction is either the direction before, or the direction after that point
- Throws:
DrawRuntimeException
- when position is NaN, less than 0.0, or more than line length.
-
closestPointOnPolyLine
Description copied from interface:PolyLine
Project a Point on this PolyLine. If the the projected points lies outside this PolyLine, the nearest end point of this PolyLine is returned. Otherwise the returned point lies between the end points of this PolyLine.- Specified by:
closestPointOnPolyLine
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
point
- P; the point to project onto this PolyLine- Returns:
- P; either the start point, or the end point of this PolyLine or a Point that lies somewhere along this PolyLine.
-
projectOrthogonal
Description copied from interface:Project
Project a point onto this object. For PolyLines and Polygons, there may be multiple valid solutions. In that case the solution that lies on the closest segment is returned. If there is no valid solution on the closest segment, null is returned.- Specified by:
projectOrthogonal
in interfaceProject<Point2d>
- Parameters:
point
- P; the point- Returns:
- P; the projection of the point (may be null if no sensible projection is possible). If the result is not null; the result lies somewhere on this object.
- Throws:
NullPointerException
- when point is null;
-
projectOrthogonalExtended
Description copied from interface:Project
Project a point onto this object. For PolyLines and Polygons, there may be multiple valid solutions. In that case the solution that lies on the closest segment is returned.- Specified by:
projectOrthogonalExtended
in interfaceProject<Point2d>
- Parameters:
point
- P; the point- Returns:
- P; the projection of the point. This result cannot be null, but it may not lie on this object, but, in stead, lie on a line, or plane that extends this object
- Throws:
NullPointerException
- when point is null;
-
projectOrthogonalFractional
Description copied from interface:Project
Project a point onto this object. For PolyLines and Polygons, there may be multiple valid solutions. In that case the solution that lies on the closest segment is returned. If there is no valid solution on the closest segment, NaN is returned.- Specified by:
projectOrthogonalFractional
in interfaceProject<Point2d>
- Parameters:
point
- P; the point- Returns:
- double; the fractional position of the projection of the point (may be NaN if no sensible projection is possible). If the result is not NaN; the result lies somewhere on this object.
- Throws:
NullPointerException
- when point is null;
-
projectOrthogonalFractionalExtended
Description copied from interface:Project
Project a point onto this object. For PolyLines and Polygons, there may be multiple valid solutions. In that case the solution that lies on the closest segment is returned.- Specified by:
projectOrthogonalFractionalExtended
in interfaceProject<Point2d>
- Parameters:
point
- P; the point- Returns:
- double; the fractional position of the projection of the point. This result cannot be NaN, but it may be outside the range 0.0 .. 1.0.
- Throws:
NullPointerException
- when point is null;
-
extract
Description copied from interface:PolyLine
Create a new PolyLine that covers a sub-section of this PolyLine.- Specified by:
extract
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
start
- double; length along this PolyLine where the sub-section starts, valid range [0..end)end
- double; length along this PolyLine where the sub-section ends, valid range (start..length (length is the length of this PolyLine)- Returns:
- L; a new PolyLine covering the selected sub-section
- Throws:
DrawRuntimeException
- when start >= end, or start < 0, or end > length
-
truncate
Description copied from interface:PolyLine
Truncate this PolyLine at the given length (less than the length of the line, and larger than zero) and return a new line.- Specified by:
truncate
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
position
- double; the position along the line where to truncate the line- Returns:
- L; a new PolyLine that follows this PolyLine, but ends at the position where line.getLength() == lengthSI
- Throws:
DrawRuntimeException
- when position less than 0.0 or more than line length.
-
offsetLine
public PolyLine2d offsetLine(double offset, double circlePrecision, double offsetMinimumFilterValue, double offsetMaximumFilterValue, double offsetFilterRatio, double minimumOffset) throws IllegalArgumentException Description copied from interface:PolyLine
Construct an offset line. This is similar to what geographical specialists call buffering, except that this method only construct a new line on one side of the reference line and does not add half disks (or miters) around the end points. This method tries to strike a delicate balance between generating too few and too many points to approximate arcs. Noise in this (the reference line) can cause major artifacts in the offset line.
In the 3D version the offset is parallel to the X-Y plane.- Specified by:
offsetLine
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
offset
- double; the offset; positive values indicate left of the reference line, negative values indicate right of the reference linecirclePrecision
- double; precision of approximation of arcs; the line segments that are used to approximate an arc will not deviate from the exact arc by more than this valueoffsetMinimumFilterValue
- double; noise in the reference line less than this value is always filteredoffsetMaximumFilterValue
- double; noise in the reference line greater than this value is never filteredoffsetFilterRatio
- double; noise in the reference line less than offset / offsetFilterRatio is filtered except when the resulting value exceeds offsetMaximumFilterValueminimumOffset
- double; an offset value less than this value is treated as 0.0- Returns:
- L; a PolyLine at the specified offset from the reference line
- Throws:
IllegalArgumentException
- when offset is NaN, or circlePrecision, offsetMinimumFilterValue, offsetMaximumfilterValue, offsetFilterRatio, or minimumOffset is not positive, or NaN, or offsetMinimumFilterValue >= offsetMaximumFilterValue
-
offsetLine
public PolyLine2d offsetLine(double offsetAtStart, double offsetAtEnd, double circlePrecision, double offsetMinimumFilterValue, double offsetMaximumFilterValue, double offsetFilterRatio, double minimumOffset) throws IllegalArgumentException, DrawRuntimeException Description copied from interface:PolyLine
Construct an offset line. This is similar to what geographical specialists call buffering, except that this method only construct a new line on one side of the reference line and does not add half disks (or miters) around the end points. This method tries to strike a delicate balance between generating too few and too many points to approximate arcs. Noise in this (the reference line) can cause major artifacts in the offset line.
In the 3D version the offset is parallel to the X-Y plane.- Specified by:
offsetLine
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
offsetAtStart
- double; the offset at the start of this line; positive values indicate left of the reference line, negative values indicate right of the reference lineoffsetAtEnd
- double; the offset at the end of this line; positive values indicate left of the reference line, negative values indicate right of the reference linecirclePrecision
- double; precision of approximation of arcs; the line segments that are used to approximate an arc will not deviate from the exact arc by more than this valueoffsetMinimumFilterValue
- double; noise in the reference line less than this value is always filteredoffsetMaximumFilterValue
- double; noise in the reference line greater than this value is never filteredoffsetFilterRatio
- double; noise in the reference line less than offset / offsetFilterRatio is filtered except when the resulting value exceeds offsetMaximumFilterValueminimumOffset
- double; an offset value less than this value is treated as 0.0- Returns:
- L; a PolyLine at the specified offset from the reference line
- Throws:
IllegalArgumentException
- when offset is NaN, or circlePrecision, offsetMinimumFilterValue, offsetMaximumfilterValue, offsetFilterRatio, or minimumOffset is not positive, or NaN, or offsetMinimumFilterValue >= offsetMaximumFilterValueDrawRuntimeException
- Only if P is PolyLine3d and the line cannot be projected into 2d
-
transitionLine
public PolyLine2d transitionLine(PolyLine2d endLine, PolyLine.TransitionFunction transition) throws DrawRuntimeException Description copied from interface:PolyLine
Make a transition line from this PolyLine to another PolyLine using a user specified function.- Specified by:
transitionLine
in interfacePolyLine<PolyLine2d,
Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
endLine
- L; the other PolyLinetransition
- TransitionFunction; how the results changes from this line to the other line- Returns:
- L; a transition between this PolyLine and the other PolyLine
- Throws:
DrawRuntimeException
- when construction of some point along the way fails. E.g. when the transition function returns NaN.
-
projectRay
Find a location on this PolyLine2d that is a reasonable projection of a Ray on this line. The result (if not NaN) lies on a line perpendicular to the direction of the Ray and on some segment of this PolyLine. This method attempts to give continuous results for continuous changes of the Ray that must be projected. There are cases where this is simply impossible, or the optimal result is ambiguous. In these cases this method will return something that is hopefully good enough.- Parameters:
ray
- Ray2d; the Ray- Returns:
- double; length along this PolyLine (some value between 0 and the length of this PolyLine) where ray projects, or NaN if there is no solution
- Throws:
NullPointerException
- when ray is null
-
toPath2D
Construct a Path2D from this PolyLine2d. The result is NOT cached (in the current implementation).- Returns:
- Path2D; newly construct Path2D consisting solely of straight segments.
-
toString
Description copied from interface:Drawable
Produce a string describing the Drawable using default conversion for the (double) coordinate values. Regrettably, it is not allowed to provide a default implementation here. -
toString
Description copied from interface:Drawable
Produce a String describing the Drawable.- Specified by:
toString
in interfaceDrawable<Point2d>
- Parameters:
doubleFormat
- String; a format string (something like "%6.3f") which will be used to render every coordinate value)doNotIncludeClassName
- boolean; if true; the output of toString is not prefixed by the class name. This is useful for concatenating the textual representation of lots of Drawables (e.g. an array, or a List).- Returns:
- String; textual representation of the Drawable
-
hashCode
public int hashCode() -
equals
-