Package org.djutils.draw.line
Class PolyLine2d
java.lang.Object
org.djutils.draw.line.PolyLine2d
- All Implemented Interfaces:
Serializable,Iterable<Point2d>,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-2025 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, Wouter Schakel
- 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, NO_FILTER -
Constructor Summary
ConstructorsConstructorDescriptionPolyLine2d(boolean copyNeeded, double epsilon, double[] x, double[] y) Construct a new PolyLine2d from an array of double x values and an array of double y values.PolyLine2d(double[] x, double[] y) Construct a new PolyLine2d from an array of x-values and an array of y-values.PolyLine2d(double epsilon, 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(double epsilon, Path2D path) Construct a new PolyLine2d from a Path2D.PolyLine2d(double epsilon, Iterator<Point2d> iterator) Construct a new PolyLine2d from an iterator that yields Point2d objects.PolyLine2d(double epsilon, List<Point2d> pointList) Construct a new PolyLine2d from a List<Point2d>.PolyLine2d(double epsilon, Point2d[] points) Construct a new PolyLine2d from an array of Point2d.PolyLine2d(double epsilon, Point2d point1, Point2d point2, Point2d... otherPoints) Construct a new PolyLine2d from two or more Point2d arguments.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 TypeMethodDescriptionclosestPointOnPolyLine(Point2d point) Project a Point on this PolyLine.static PolyLine2dconcatenate(double tolerance, PolyLine2d... lines) Concatenate several PolyLine2d instances.static PolyLine2dconcatenate(double tolerance, PolyLine2d line1, PolyLine2d line2) Concatenate two PolyLine2d instances.static PolyLine2dconcatenate(PolyLine2d... lines) Concatenate several PolyLine2d instances.booleanextract(double start, double end) Create a new PolyLine that covers a sub-section of this PolyLine.final Point2dget(int i) Return one of the points of this line.Retrieve the bounding rectangle of the object in absolute coordinates.doubleReturn the length of this line.final DirectedPoint2dgetLocation(double position) Get the location at a position on the line, with its direction.final DirectedPoint2dgetLocationExtended(double position) Get the location at a position on the line, with its direction.getSegment(int index) Extract one LineSegment of this PolyLine, or Polygon.final doublegetX(int i) Return the x-coordinate of a point of this PolyLine.final doublegetY(int i) Return the y-coordinate of a point of this PolyLine.inthashCode()instantiate(double epsilon, List<Point2d> pointList) Constructor that can be accessed as a method (used to implement default methods in this interface).iterator()iteratorToList(Iterator<Point2d> iterator) Build a list from the Point2d objects that an iterator provides.final doublelengthAtIndex(int index) Access the internal lengthIndexedLine.protected static double[]Make an array of double an fill it with the appropriate coordinate of points.final PolyLine2dnoiseFilteredLine(double noiseLevel) Construct a new PolyLine that is equal to this line except for segments that are shorter than thenoiseLevel.final PolyLine2doffsetLine(double[] relativeFractions, double[] offsets, double offsetMinimumFilterValue) Create a line at linearly varying offset from this line.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 doubleProject a point onto this object.doubleProject a point onto this object.doubleprojectRay(Ray2d ray) Find a location on this PolyLine2d that is a reasonable projection of a Ray on this line.intsize()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, waitMethods inherited from interface org.djutils.draw.Drawable
getPointList, toString, toStringMethods inherited from interface org.djutils.draw.Drawable2d
getDimensionsMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.djutils.draw.line.PolyLine
extractFractional, filterNearDuplicates, find, getFirst, getLast, getLocationFraction, getLocationFraction, getLocationFractionExtended, instantiate, offsetLine, offsetLine, reverse
-
Constructor Details
-
PolyLine2d
PolyLine2d(boolean copyNeeded, double epsilon, double[] x, double[] y) Construct a new PolyLine2d from an array of double x values and an array of double y values.- Parameters:
copyNeeded- iftrue; a deep copy of the points array is stored instead of the provided arrayepsilon- minimum distance between points to be considered different (these will not be filtered out)x- the x-coordinates of the pointsy- the y-coordinates of the points- Throws:
NullPointerException- wheniteratorisnullIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points), orxandydiffer in length
-
PolyLine2d
public PolyLine2d(double x, double y, double heading) Construct a degenerate PolyLine2d (consisting of only one point).- Parameters:
x- the x-coordinatey- the y-coordinateheading- the heading in radians- Throws:
ArithmeticException- whenx,y, orheadingisNaNIllegalArgumentException- when or heading is infinite
-
PolyLine2d
Construct a degenerate PolyLine2d (consisting of only one point).- Parameters:
p- the point of the degenerate PolyLine2dheading- the heading in radians- Throws:
NullPointerException- whenpisnullArithmeticException- whenheadingisNaNIllegalArgumentException- whenheadingis infinite
-
PolyLine2d
Construct a degenerate PolyLine2d (consisting of only one point).- Parameters:
directedPoint2d- point and heading (DirZ) of the degenerate PolyLine2d- Throws:
NullPointerException- whenpisnullArithmeticException- whenheadingisNaNIllegalArgumentException- whenheadingis infinite
-
PolyLine2d
public PolyLine2d(double[] x, double[] y) 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- the x-coordinates of the pointsy- the y-coordinates of the points- Throws:
NullPointerException- when any of the arrays isnullIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points, or the arrays do not have the same length)
-
PolyLine2d
public PolyLine2d(double epsilon, double[] x, double[] y) 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:
epsilon- minimum distance between points to be considered different (these will not be filtered out)x- the x-coordinates of the pointsy- the y-coordinates of the points- Throws:
NullPointerException- when any of the arrays isnullIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points, or the arrays do not have the same length)
-
PolyLine2d
Construct a new PolyLine2d from an array of Point2d.- Parameters:
points- the array of points to construct this PolyLine2d from.- Throws:
NullPointerException- when the array isnullIllegalArgumentException- 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:
epsilon- minimum distance between points to be considered different (these will not be filtered out)points- the array of points to construct this PolyLine2d from.- Throws:
NullPointerException- when the array isnullIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from two or more Point2d arguments.- Parameters:
point1- starting point of the PolyLine2dpoint2- second point of the PolyLine2dotherPoints- additional points of the PolyLine2d (may benull, or have zero length)- Throws:
NullPointerException- whenpoint1, orpoint2isnull, orotherPointscontains anullvalueIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from two or more Point2d arguments.- Parameters:
epsilon- minimum distance between points to be considered different (these will not be filtered out)point1- starting point of the PolyLine2dpoint2- second point of the PolyLine2dotherPoints- additional points of the PolyLine2d (may benull, or have zero length)- Throws:
NullPointerException- whenpoint1, orpoint2isnull, orotherPointscontains anullvalueIllegalArgumentException- 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 that will provide all points that constitute the new PolyLine2d- Throws:
NullPointerException- wheniteratorisnull, or yields anullvalueIllegalArgumentException- when the iterator provides too few points, or some adjacent identical points)
-
PolyLine2d
Construct a new PolyLine2d from an iterator that yields Point2d objects.- Parameters:
epsilon- minimum distance between points to be considered different (these will not be filtered out)iterator- iterator that will provide all points that constitute the new PolyLine2d- Throws:
NullPointerException- wheniteratorisnull, or yields anullvalueIllegalArgumentException- when the iterator provides too few points, or some adjacent identical points)
-
PolyLine2d
Construct a new PolyLine2d from a List<Point2d>.- Parameters:
pointList- the list of points to construct the new PolyLine2d from.- Throws:
NullPointerException- whenpointListisnull, or contains anullvalueIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from a List<Point2d>.- Parameters:
epsilon- minimum distance between points to be considered different (these will not be filtered out)pointList- the list of points to construct the new PolyLine2d from.- Throws:
NullPointerException- whenpointListisnull, or contains anullvalueIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from a Path2D.- Parameters:
path- the Path2D to construct this PolyLine2d from.- Throws:
NullPointerException- whenpathisnullIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from a Path2D.- Parameters:
epsilon- minimum distance between points to be considered different (these will not be filtered out)path- the Path2D to construct this PolyLine2d from.- Throws:
NullPointerException- whenpathisnullIllegalArgumentException- when the provided points do not constitute a valid line (too few points or identical adjacent points)
-
PolyLine2d
Construct a new PolyLine2d from an existing one. This constructor is primarily intended for use in extending classes.- Parameters:
polyLine- the existingPolyLine2d
-
-
Method Details
-
makeArray
Make an array of double an fill it with the appropriate coordinate of points.- Parameters:
points- array of pointsgetter- function that obtains the intended coordinate- Returns:
- array of double filled with the requested coordinate values
-
iteratorToList
Build a list from the Point2d objects that an iterator provides.- Parameters:
iterator- the iterator that will provide the points- Returns:
- a list of the points provided by the
iterator
-
instantiate
Description copied from interface:PolyLineConstructor that can be accessed as a method (used to implement default methods in this interface).- Specified by:
instantiatein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
epsilon- minimum distance between points to be considered different (these will not be filtered out)pointList- a list of points- Returns:
- the new PolyLine
-
size
public int size()Description copied from interface:DrawableRetrieve the number of points that make up the object. -
get
Description copied from interface:PolyLineReturn one of the points of this line.- Specified by:
getin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
i- the index of the requested point- Returns:
- the point at the specified index
-
getX
public final double getX(int i) Description copied from interface:PolyLineReturn the x-coordinate of a point of this PolyLine.- Specified by:
getXin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
i- the index of the requested x-coordinate- Returns:
- the x-coordinate of the requested point of this PolyLine
-
getY
public final double getY(int i) Description copied from interface:PolyLineReturn the y-coordinate of a point of this PolyLine.- Specified by:
getYin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
i- the index of the requested y-coordinate- Returns:
- the y-coordinate of the requested point of this PolyLine
-
getSegment
Description copied from interface:PolyLineExtract one LineSegment of this PolyLine, or Polygon.- Specified by:
getSegmentin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
index- the rank number of the segment; must be in range 0..Size() - 2 for PolyLine, or 0.. Size() - 1 for Polygon.- Returns:
- the LineSegment that connects point index to point index + 1
-
lengthAtIndex
public final double lengthAtIndex(int index) Description copied from interface:PolyLineAccess the internal lengthIndexedLine. Return the cumulative length up to pointindexof this line- Specified by:
lengthAtIndexin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
index- the index- Returns:
- the cumulative length of this line up to point
index
-
getLength
public double getLength()Description copied from interface:PolyLineReturn the length of this line. This is not the number of points; it is the sum of the lengths of the segments.- Specified by:
getLengthin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Returns:
- the length of this line
-
iterator
-
getAbsoluteBounds
Description copied from interface:Drawable2dRetrieve the bounding rectangle of the object in absolute coordinates.- Specified by:
getAbsoluteBoundsin interfaceDrawable2d- Returns:
- the bounding box of the object in absolute coordinates
-
noiseFilteredLine
Description copied from interface:PolyLineConstruct a new PolyLine that is equal to this line except for segments that are shorter than thenoiseLevel. The result is guaranteed to start with the first point of this line and end with the last point of this line.- Specified by:
noiseFilteredLinein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
noiseLevel- the minimum segment length that is not removed- Returns:
- the filtered line
-
concatenate
Concatenate several PolyLine2d instances.- Parameters:
lines- One or more PolyLine2d objects. The last point of the first <strong>must</strong> match the first of the second, etc.- Returns:
- PolyLine2d
- Throws:
NullPointerException- whenlinesisnullIllegalArgumentException- if zero lines are given, or when there is a gap between consecutive lines
-
concatenate
Concatenate two PolyLine2d instances. This method is separate for efficiency reasons.- Parameters:
tolerance- the tolerance between the end point of a line and the first point of the next lineline1- first lineline2- second line- Returns:
- the concatenation of the two lines
- Throws:
NullPointerException- whenline1, orline2isnullIllegalArgumentException- when there is a gap larger thantolerancebetween the two lines
-
concatenate
Concatenate several PolyLine2d instances.- Parameters:
tolerance- the tolerance between the end point of a line and the first point of the next linelines- 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:
- the concatenation of the lines
- Throws:
NullPointerException- whenlinesisnull, or contains anullvalueIllegalArgumentException- if zero lines are given, or when there is a gap larger thantolerancebetween consecutive lines
-
getLocationExtended
Description copied from interface:PolyLineGet 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:
getLocationExtendedin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
position- the position on the line for which to calculate the point on, before, or after the line- Returns:
- 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:PolyLineGet the location at a position on the line, with its direction. Position should be between 0.0 and line length.- Specified by:
getLocationin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
position- the position on the line for which to calculate the point on the line- Returns:
- 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
-
closestPointOnPolyLine
Description copied from interface:PolyLineProject 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:
closestPointOnPolyLinein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
point- the point to project onto this PolyLine- Returns:
- either the start point, or the end point of this PolyLine or a Point that lies somewhere along this PolyLine as a directed point
-
projectOrthogonal
Description copied from interface:ProjectProject 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,nullis returned.- Specified by:
projectOrthogonalin interfaceProject<Point2d>- Parameters:
point- the point- Returns:
- 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- whenpointisnull
-
projectOrthogonalExtended
Description copied from interface:ProjectProject 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:
projectOrthogonalExtendedin interfaceProject<Point2d>- Parameters:
point- the point- Returns:
- 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- whenpointisnull
-
projectOrthogonalFractional
Description copied from interface:ProjectProject 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,NaNis returned.- Specified by:
projectOrthogonalFractionalin interfaceProject<Point2d>- Parameters:
point- the point- Returns:
- the fractional position of the projection of the point (may be
NaNif no sensible projection is possible). If the result is notNaN; the result lies somewhere on this object. - Throws:
NullPointerException- whenpointisnull
-
projectOrthogonalFractionalExtended
Description copied from interface:ProjectProject 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:
projectOrthogonalFractionalExtendedin interfaceProject<Point2d>- Parameters:
point- the point- Returns:
- 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- whenpointisnull
-
extract
Description copied from interface:PolyLineCreate a new PolyLine that covers a sub-section of this PolyLine.- Specified by:
extractin interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
start- length along this PolyLine where the sub-section starts, valid range [0..end)end- length along this PolyLine where the sub-section ends, valid range (start..length(length is the length of this PolyLine)- Returns:
- a new
PolyLinecovering the selected sub-section
-
truncate
Description copied from interface:PolyLineTruncate this PolyLine at the given length (less than the length of the line, and larger than zero) and return a new line.- Specified by:
truncatein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
position- the position along the line where to truncate the line- Returns:
- a new PolyLine that follows this PolyLine, but ends at the position where line.getLength() == lengthSI
-
offsetLine
public PolyLine2d offsetLine(double offset, double circlePrecision, double offsetMinimumFilterValue, double offsetMaximumFilterValue, double offsetFilterRatio, double minimumOffset) Description copied from interface:PolyLineConstruct 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 inthis(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:
offsetLinein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
offset- the offset; positive values indicate left of the reference line, negative values indicate right of the reference linecirclePrecision- 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- noise in the reference line less than this value is always filteredoffsetMaximumFilterValue- noise in the reference line greater than this value is never filteredoffsetFilterRatio- noise in the reference line less thanoffset / offsetFilterRatiois filtered except when the resulting value exceedsoffsetMaximumFilterValueminimumOffset- an offset value less than this value is treated as 0.0- Returns:
- a PolyLine at the specified offset from the reference line
-
offsetLine
public PolyLine2d offsetLine(double offsetAtStart, double offsetAtEnd, double circlePrecision, double offsetMinimumFilterValue, double offsetMaximumFilterValue, double offsetFilterRatio, double minimumOffset) Description copied from interface:PolyLineConstruct 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 inthis(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:
offsetLinein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
offsetAtStart- the offset at the start of this line; positive values indicate left of the reference line, negative values indicate right of the reference lineoffsetAtEnd- the offset at the end of this line; positive values indicate left of the reference line, negative values indicate right of the reference linecirclePrecision- 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- noise in the reference line less than this value is always filteredoffsetMaximumFilterValue- noise in the reference line greater than this value is never filteredoffsetFilterRatio- noise in the reference line less thanoffset / offsetFilterRatiois filtered except when the resulting value exceedsoffsetMaximumFilterValueminimumOffset- an offset value less than this value is treated as 0.0- Returns:
- a PolyLine at the specified offset from the reference line
-
transitionLine
Description copied from interface:PolyLineMake a transition line from this PolyLine to another PolyLine using a user specified function.- Specified by:
transitionLinein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
endLine- the other PolyLinetransition- defines how the results changes from thislineto theendLine- Returns:
- a transition between this PolyLine and the other PolyLine
-
offsetLine
public final PolyLine2d offsetLine(double[] relativeFractions, double[] offsets, double offsetMinimumFilterValue) Description copied from interface:PolyLineCreate a line at linearly varying offset from this line. The offset may change linearly from its initial value at the start of the reference line via a number of intermediate offsets at intermediate positions to its final offset value at the end of the reference line.- Specified by:
offsetLinein interfacePolyLine<PolyLine2d,Point2d, Ray2d, DirectedPoint2d, LineSegment2d> - Parameters:
relativeFractions- positional fractions for which the offsets have to be generatedoffsets- offsets at the relative positions (positive value is Left, negative value is Right)offsetMinimumFilterValue- noise in the reference line less than this value is filtered- Returns:
- the PolyLine2d of the line at multi-linearly changing offset of the reference line
-
projectRay
Find a location on this PolyLine2d that is a reasonable projection of a Ray on this line. The result (if notNaN) lies on a line perpendicular to the direction of theRayand on some segment of thisPolyLine. This method attempts to give continuous results for continuous changes of theRaythat 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- the Ray- Returns:
- length along this
PolyLine(some value between 0 and the length of thisPolyLine) whererayprojects, orNaNif there is no solution - Throws:
NullPointerException- whenrayisnull
-
toPath2D
Construct a Path2D from this PolyLine2d. The result is NOT cached (in the current implementation).- Returns:
- newly constructed
Path2Dconsisting solely of straight segments.
-
toString
Description copied from interface:DrawableProduce 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:DrawableProduce a String describing the Drawable.- Specified by:
toStringin interfaceDrawable<Point2d>- Parameters:
doubleFormat- a format string (something like "%6.3f") which will be used to render every coordinate value)doNotIncludeClassName- iftrue; the output oftoStringis 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:
- textual representation of the Drawable
-
hashCode
public int hashCode() -
equals
-