math.geom2d.polygon
Class Polyline2D
- java.lang.Object
-
- math.geom2d.curve.AbstractContinuousCurve2D
-
- math.geom2d.polygon.LinearCurve2D
-
- math.geom2d.polygon.Polyline2D
-
- All Implemented Interfaces:
- java.lang.Cloneable, CirculinearContinuousCurve2D, CirculinearCurve2D, CirculinearShape2D, ContinuousCurve2D, Curve2D, ContinuousOrientedCurve2D, OrientedCurve2D, GeometricObject2D, Shape2D
public class Polyline2D extends LinearCurve2D implements CirculinearContinuousCurve2D, java.lang.Cloneable
A polyline is a continuous curve where each piece of the curve is a LineSegment2D.
-
-
Constructor Summary
Constructors Constructor and Description Polyline2D()Polyline2D(java.util.Collection<? extends Point2D> vertices)Polyline2D(double[] xcoords, double[] ycoords)Polyline2D(int nVertices)Creates a new polyline by allocating enough memory for the specified number of vertices.Polyline2D(LinearCurve2D lineString)Polyline2D(Point2D... vertices)Polyline2D(Point2D initialPoint)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description booleanalmostEquals(GeometricObject2D obj, double eps)Checks if the two objects are similar up to a given threshold value.java.awt.geom.GeneralPathappendPath(java.awt.geom.GeneralPath path)Append the path of the curve to the given path.java.awt.geom.GeneralPathasGeneralPath()Returns a general path iterator.Polyline2Dclone()Deprecated.use copy constructor instead (0.11.2)java.util.Collection<? extends Polyline2D>continuousCurves()Returns the collection of continuous curves which constitute this curve.static Polyline2Dcreate(java.util.Collection<? extends Point2D> points)Static factory for creating a new Polyline2D from a collection of points.static Polyline2Dcreate(Point2D... points)Static factory for creating a new Polyline2D from an array of points.LineSegment2Dedge(int index)Returns the i-th edge of this linear curve.intedgeNumber()Returns the number of edges of this linear curve.java.util.Collection<LineSegment2D>edges()Returns an array of LineSegment2D.booleanequals(java.lang.Object object)doublegetT1()Deprecated.replaced by t1() (since 0.11.1).booleanisClosed()Returns false, as Polyline2D is open by definition.booleanisInside(Point2D pt)Returns true if the point is 'inside' the domain bounded by the curve.LineSegment2DlastEdge()Point2DlastPoint()Returns the last point of this polyline, or null if the polyline does not contain any point.Point2Dpoint(double t)Returns the point located at the given position on the curve.Polyline2Dreverse()Returns the polyline with same points considered in reverse order.Polyline2Dsimplify(double distMax)Returns a simplified version of this polyline, by using Douglas-Peucker algorithm.Polyline2DsubCurve(double t0, double t1)Return an instance of Polyline2D.doublet1()Returns the number of points in the polyline, minus one.Polyline2Dtransform(AffineTransform2D trans)Transforms the shape by an affine transform.CirculinearContinuousCurve2Dtransform(CircleInversion2D inv)Transforms the shape by a circle inversion.doublewindingAngle(Point2D point)Return the angle portion that the curve turn around the given point.-
Methods inherited from class math.geom2d.polygon.LinearCurve2D
addVertex, boundingBox, buffer, clearVertices, clip, closestVertexIndex, contains, contains, curvature, distance, distance, draw, firstEdge, firstPoint, getT0, insertVertex, intersections, isBounded, isEmpty, isSingular, leftTangent, length, length, parallel, position, position, project, removeVertex, removeVertex, rightTangent, setVertex, signedDistance, signedDistance, singularPoints, smoothPieces, t0, vertex, vertexArray, vertexIterator, vertexNumber, vertices
-
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D
asAwtShape, asPolyline
-
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface math.geom2d.circulinear.CirculinearContinuousCurve2D
clip, parallel, smoothPieces
-
Methods inherited from interface math.geom2d.circulinear.CirculinearCurve2D
length, length, position
-
Methods inherited from interface math.geom2d.circulinear.CirculinearShape2D
buffer
-
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
asPolyline, curvature, leftTangent, rightTangent
-
Methods inherited from interface math.geom2d.domain.OrientedCurve2D
signedDistance, signedDistance
-
Methods inherited from interface math.geom2d.curve.Curve2D
asAwtShape, draw, firstPoint, getT0, intersections, isSingular, position, project, singularPoints, t0, vertices
-
-
-
-
Constructor Detail
-
Polyline2D
public Polyline2D()
-
Polyline2D
public Polyline2D(int nVertices)
Creates a new polyline by allocating enough memory for the specified number of vertices.- Parameters:
nVertices-
-
Polyline2D
public Polyline2D(Point2D initialPoint)
-
Polyline2D
public Polyline2D(Point2D... vertices)
-
Polyline2D
public Polyline2D(java.util.Collection<? extends Point2D> vertices)
-
Polyline2D
public Polyline2D(double[] xcoords, double[] ycoords)
-
Polyline2D
public Polyline2D(LinearCurve2D lineString)
-
-
Method Detail
-
create
public static Polyline2D create(java.util.Collection<? extends Point2D> points)
Static factory for creating a new Polyline2D from a collection of points.- Since:
- 0.8.1
-
create
public static Polyline2D create(Point2D... points)
Static factory for creating a new Polyline2D from an array of points.- Since:
- 0.8.1
-
simplify
public Polyline2D simplify(double distMax)
Returns a simplified version of this polyline, by using Douglas-Peucker algorithm.- Specified by:
simplifyin classLinearCurve2D
-
edges
public java.util.Collection<LineSegment2D> edges()
Returns an array of LineSegment2D. The number of edges is the number of vertices minus one.- Specified by:
edgesin classLinearCurve2D- Returns:
- the edges of the polyline
-
edgeNumber
public int edgeNumber()
Description copied from class:LinearCurve2DReturns the number of edges of this linear curve.- Specified by:
edgeNumberin classLinearCurve2D
-
edge
public LineSegment2D edge(int index)
Description copied from class:LinearCurve2DReturns the i-th edge of this linear curve.- Specified by:
edgein classLinearCurve2D
-
lastEdge
public LineSegment2D lastEdge()
- Specified by:
lastEdgein classLinearCurve2D
-
transform
public CirculinearContinuousCurve2D transform(CircleInversion2D inv)
Description copied from interface:CirculinearShape2DTransforms the shape by a circle inversion. The result is still an instance a CirculinearShape2D.- Specified by:
transformin interfaceCirculinearContinuousCurve2D- Specified by:
transformin interfaceCirculinearCurve2D- Specified by:
transformin interfaceCirculinearShape2D- Parameters:
inv- the circle inversion- Returns:
- the transformed shape
-
windingAngle
public double windingAngle(Point2D point)
Description copied from interface:OrientedCurve2DReturn the angle portion that the curve turn around the given point. Result is a signed angle.- Specified by:
windingAnglein interfaceOrientedCurve2D- Parameters:
point- a point of the plane- Returns:
- a signed angle
-
isInside
public boolean isInside(Point2D pt)
Description copied from interface:OrientedCurve2DReturns true if the point is 'inside' the domain bounded by the curve.- Specified by:
isInsidein interfaceOrientedCurve2D- Parameters:
pt- a point in the plane- Returns:
- true if the point is on the left side of the curve.
-
isClosed
public boolean isClosed()
Returns false, as Polyline2D is open by definition.- Specified by:
isClosedin interfaceContinuousCurve2D
-
point
public Point2D point(double t)
Description copied from interface:Curve2DReturns the point located at the given position on the curve. If the parameter lies outside the definition range, the parameter corresponding to the closest bound is used instead. This method can be used to draw an approximated outline of a curve, by selecting multiple values for t and drawing lines between them.
-
t1
public double t1()
Returns the number of points in the polyline, minus one.
-
getT1
@Deprecated public double getT1()
Deprecated. replaced by t1() (since 0.11.1).
-
lastPoint
public Point2D lastPoint()
Returns the last point of this polyline, or null if the polyline does not contain any point.- Specified by:
lastPointin interfaceCurve2D- Overrides:
lastPointin classAbstractContinuousCurve2D- Returns:
- the last point of the curve.
- See Also:
Curve2D.t1(),Curve2D.point(double)
-
reverse
public Polyline2D reverse()
Returns the polyline with same points considered in reverse order. Reversed polyline keep same references as original polyline.- Specified by:
reversein interfaceCirculinearContinuousCurve2D- Specified by:
reversein interfaceCirculinearCurve2D- Specified by:
reversein interfaceContinuousCurve2D- Specified by:
reversein interfaceCurve2D- Specified by:
reversein interfaceContinuousOrientedCurve2D- Specified by:
reversein interfaceOrientedCurve2D
-
continuousCurves
public java.util.Collection<? extends Polyline2D> continuousCurves()
Description copied from interface:Curve2DReturns the collection of continuous curves which constitute this curve.- Specified by:
continuousCurvesin interfaceCirculinearCurve2D- Specified by:
continuousCurvesin interfaceCurve2D- Overrides:
continuousCurvesin classLinearCurve2D- Returns:
- a collection of continuous curves.
-
subCurve
public Polyline2D subCurve(double t0, double t1)
Return an instance of Polyline2D. If t1 is lower than t0, return an instance of Polyline2D with zero points.- Specified by:
subCurvein interfaceCirculinearContinuousCurve2D- Specified by:
subCurvein interfaceCirculinearCurve2D- Specified by:
subCurvein interfaceContinuousCurve2D- Specified by:
subCurvein interfaceCurve2D- Specified by:
subCurvein interfaceContinuousOrientedCurve2D- Parameters:
t0- position of the start of the sub-curvet1- position of the end of the sub-curve- Returns:
- the portion of original curve comprised between t0 and t1.
-
transform
public Polyline2D transform(AffineTransform2D trans)
Description copied from interface:Shape2DTransforms the shape by an affine transform. Subclasses may override the type of returned shape.- Specified by:
transformin interfaceContinuousCurve2D- Specified by:
transformin interfaceCurve2D- Specified by:
transformin interfaceContinuousOrientedCurve2D- Specified by:
transformin interfaceOrientedCurve2D- Specified by:
transformin interfaceShape2D- Parameters:
trans- an affine transform- Returns:
- the transformed shape
-
appendPath
public java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
Description copied from interface:ContinuousCurve2DAppend the path of the curve to the given path.- Specified by:
appendPathin interfaceContinuousCurve2D- Parameters:
path- a path to modify- Returns:
- the modified path
-
asGeneralPath
public java.awt.geom.GeneralPath asGeneralPath()
Returns a general path iterator.- Overrides:
asGeneralPathin classLinearCurve2D
-
almostEquals
public boolean almostEquals(GeometricObject2D obj, double eps)
Description copied from interface:GeometricObject2DChecks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.- Specified by:
almostEqualsin interfaceGeometricObject2D- Parameters:
obj- the object to compareeps- a threshold value, for example the minimal coordinate difference- Returns:
- true if both object have the same value up to the threshold
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
clone
@Deprecated public Polyline2D clone()
Deprecated. use copy constructor instead (0.11.2)- Specified by:
clonein interfaceCurve2D- Specified by:
clonein classAbstractContinuousCurve2D
-
-
DMelt 3.0 © DataMelt by jWork.ORG