math.geom2d.polygon
Class LinearCurve2D
- java.lang.Object
-
- math.geom2d.curve.AbstractContinuousCurve2D
-
- math.geom2d.polygon.LinearCurve2D
-
- All Implemented Interfaces:
- java.lang.Cloneable, CirculinearContinuousCurve2D, CirculinearCurve2D, CirculinearShape2D, ContinuousCurve2D, Curve2D, ContinuousOrientedCurve2D, OrientedCurve2D, GeometricObject2D, Shape2D
- Direct Known Subclasses:
- LinearRing2D, Polyline2D
public abstract class LinearCurve2D extends AbstractContinuousCurve2D implements CirculinearContinuousCurve2D
Abstract class that is the base implementation of Polyline2D and LinearRing2D.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description booleanaddVertex(Point2D vertex)Adds a vertex at the end of this polyline.java.awt.geom.GeneralPathasGeneralPath()Returns a general path iterator.Box2DboundingBox()Returns the bounding box of this linear curve.CirculinearDomain2Dbuffer(double dist)Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.voidclearVertices()CurveSet2D<? extends LinearCurve2D>clip(Box2D box)Clips the polyline by a box.intclosestVertexIndex(Point2D point)Computes the index of the closest vertex to the input point.booleancontains(double x, double y)Checks if the shape contains the planar point defined by (x,y).booleancontains(Point2D point)Checks if the shape contains the given point.java.util.Collection<? extends LinearCurve2D>continuousCurves()Returns the collection of continuous curves which constitute this curve.doublecurvature(double t)Computes the curvature at the given position.doubledistance(double x, double y)Returns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e.doubledistance(Point2D point)Returns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.voiddraw(java.awt.Graphics2D g2)Draws the curve on the given Graphics2D object.abstract LineSegment2Dedge(int index)Returns the i-th edge of this linear curve.abstract intedgeNumber()Returns the number of edges of this linear curve.abstract java.util.Collection<LineSegment2D>edges()Returns a collection of LineSegment2D that represent the individual edges of this linear curve.LineSegment2DfirstEdge()Point2DfirstPoint()Returns the first point of the linear curve.doublegetT0()Deprecated.replaced by t0() (since 0.11.1).voidinsertVertex(int index, Point2D vertex)Inserts a vertex at a given position in the polyline.java.util.Collection<Point2D>intersections(LinearShape2D line)Returns the intersection points of the curve with the specified line.booleanisBounded()Always returns true, because a linear curve is always bounded.booleanisEmpty()Returns true if the polyline does not contain any point.booleanisSingular(double pos)Checks if a point is singular.abstract LineSegment2DlastEdge()Vector2DleftTangent(double t)Computes the left tangent at the given position.doublelength()doublelength(double pos)CirculinearContinuousCurve2Dparallel(double d)Creates a new curve, formed by the points with parameterization:p(t) = c(t) + d*n(t)/|n(t)|, with p(t) being a point of the original curve, n(t) the normal of the curve, and |n| being the norm of n.
In the case of a continuous curve formed by several smooth circulinear elements, the parallels of contiguous elements are joined by a circle arc.doubleposition(double length)doubleposition(Point2D point)Computes the position of the point on the curve.doubleproject(Point2D point)Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point.Point2DremoveVertex(int index)Removes the vertex specified by the index.booleanremoveVertex(Point2D vertex)Removes the first instance of the given vertex from this polyline.Vector2DrightTangent(double t)Computes the right tangent at the given position.voidsetVertex(int index, Point2D position)Changes the position of the i-th vertex.doublesignedDistance(double x, double y)The same as distanceSigned(Point2D), but by passing 2 double as arguments.doublesignedDistance(Point2D point)Returns the signed distance of the curve to the given point.abstract LinearCurve2Dsimplify(double distMax)Returns a simplified version of this linear curve.java.util.Collection<Point2D>singularPoints()Returns a set of singular points, i.java.util.Collection<? extends LineSegment2D>smoothPieces()Returns a set of circulinear elements, which are basis for circulinear curves.doublet0()Returns 0.Point2Dvertex(int i)Returns the i-th vertex of the polyline.Point2D[]vertexArray()Returns the collection of vertices as an array of Point2D.java.util.Iterator<Point2D>vertexIterator()Returns an iterator on the collection of points.intvertexNumber()Returns the number of vertices.java.util.Collection<Point2D>vertices()Returns the vertices of the polyline.-
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D
asAwtShape, asPolyline, clone, lastPoint
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface math.geom2d.circulinear.CirculinearContinuousCurve2D
reverse, subCurve, transform
-
Methods inherited from interface math.geom2d.domain.ContinuousOrientedCurve2D
transform
-
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
appendPath, asPolyline, isClosed
-
Methods inherited from interface math.geom2d.domain.OrientedCurve2D
isInside, windingAngle
-
Methods inherited from interface math.geom2d.curve.Curve2D
asAwtShape, clone, getT1, lastPoint, point, t1
-
Methods inherited from interface math.geom2d.GeometricObject2D
almostEquals
-
-
-
-
Method Detail
-
simplify
public abstract LinearCurve2D simplify(double distMax)
Returns a simplified version of this linear curve. Sub classes may override this method to return a more specialized type.
-
vertexIterator
public java.util.Iterator<Point2D> vertexIterator()
Returns an iterator on the collection of points.
-
vertexArray
public Point2D[] vertexArray()
Returns the collection of vertices as an array of Point2D.- Returns:
- an array of Point2D
-
addVertex
public boolean addVertex(Point2D vertex)
Adds a vertex at the end of this polyline.- Returns:
- true if the vertex was correctly added
- Since:
- 0.9.3
-
insertVertex
public void insertVertex(int index, Point2D vertex)Inserts a vertex at a given position in the polyline.- Since:
- 0.9.3
-
removeVertex
public boolean removeVertex(Point2D vertex)
Removes the first instance of the given vertex from this polyline.- Parameters:
vertex- the position of the vertex to remove- Returns:
- true if the vertex was actually removed
- Since:
- 0.9.3
-
removeVertex
public Point2D removeVertex(int index)
Removes the vertex specified by the index.- Parameters:
index- the index of the vertex to remove- Returns:
- the position of the vertex removed from the polyline
- Since:
- 0.9.3
-
setVertex
public void setVertex(int index, Point2D position)Changes the position of the i-th vertex.- Since:
- 0.9.3
-
clearVertices
public void clearVertices()
-
vertices
public java.util.Collection<Point2D> vertices()
Returns the vertices of the polyline.- Specified by:
verticesin interfaceCurve2D- Returns:
- a collection of Point2D.
- See Also:
Curve2D.singularPoints()
-
vertex
public Point2D vertex(int i)
Returns the i-th vertex of the polyline.- Parameters:
i- index of the vertex, between 0 and the number of vertices
-
vertexNumber
public int vertexNumber()
Returns the number of vertices.- Returns:
- the number of vertices
-
closestVertexIndex
public int closestVertexIndex(Point2D point)
Computes the index of the closest vertex to the input point.
-
edge
public abstract LineSegment2D edge(int index)
Returns the i-th edge of this linear curve.
-
edgeNumber
public abstract int edgeNumber()
Returns the number of edges of this linear curve.
-
edges
public abstract java.util.Collection<LineSegment2D> edges()
Returns a collection of LineSegment2D that represent the individual edges of this linear curve.- Returns:
- the edges of the polyline
-
firstEdge
public LineSegment2D firstEdge()
-
lastEdge
public abstract LineSegment2D lastEdge()
-
length
public double length()
- Specified by:
lengthin interfaceCirculinearCurve2D- Returns:
- the length of the curve
-
length
public double length(double pos)
- Specified by:
lengthin interfaceCirculinearCurve2D- Returns:
- the length from the beginning to the position given by pos
-
position
public double position(double length)
- Specified by:
positionin interfaceCirculinearCurve2D- Returns:
- the position located at a given geodesic distance from the origin
-
buffer
public CirculinearDomain2D buffer(double dist)
Description copied from interface:CirculinearShape2DComputes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.- Specified by:
bufferin interfaceCirculinearShape2D- Parameters:
dist- the maximal distance between a point of the buffer and the shape- Returns:
- the buffer of the shape
-
parallel
public CirculinearContinuousCurve2D parallel(double d)
Description copied from interface:CirculinearCurve2DCreates a new curve, formed by the points with parameterization:p(t) = c(t) + d*n(t)/|n(t)|, with p(t) being a point of the original curve, n(t) the normal of the curve, and |n| being the norm of n.
In the case of a continuous curve formed by several smooth circulinear elements, the parallels of contiguous elements are joined by a circle arc.- Specified by:
parallelin interfaceCirculinearContinuousCurve2D- Specified by:
parallelin interfaceCirculinearCurve2D- Parameters:
d- the distance between the original curve and he parallel curve.- Returns:
- the parallel curve
-
signedDistance
public double signedDistance(Point2D point)
Description copied from interface:OrientedCurve2DReturns the signed distance of the curve to the given point. The distance is positive if the point lies outside the shape, and negative if the point lies inside the shape. In both cases, absolute value of distance is equals to the distance to the border of the shape.- Specified by:
signedDistancein interfaceOrientedCurve2D- Parameters:
point- a point of the plane- Returns:
- the signed distance to the curve
-
signedDistance
public double signedDistance(double x, double y)Description copied from interface:OrientedCurve2DThe same as distanceSigned(Point2D), but by passing 2 double as arguments.- Specified by:
signedDistancein interfaceOrientedCurve2D- Parameters:
x- x-coord of a pointy- y-coord of a point- Returns:
- the signed distance of the point (x,y) to the curve
-
leftTangent
public Vector2D leftTangent(double t)
Description copied from interface:ContinuousCurve2DComputes the left tangent at the given position. If the curve is smooth at positiont, the result is the same as the tangent computed for the corresponding smooth curve, and is equal to the result of rightTangent(double). If the positiontcorresponds to a singular point, the tangent of the smooth portion beforetis computed.- Specified by:
leftTangentin interfaceContinuousCurve2D- Parameters:
t- the position on the curve- Returns:
- the left tangent vector at the curve for position t
-
rightTangent
public Vector2D rightTangent(double t)
Description copied from interface:ContinuousCurve2DComputes the right tangent at the given position. If the curve is smooth at positiont, the result is the same as the tangent computed for the corresponding smooth curve, and is equal to the result of leftTangent(double). If the positiontcorresponds to a singular point, the tangent of the smooth portion aftertis computed.- Specified by:
rightTangentin interfaceContinuousCurve2D- Parameters:
t- the position on the curve- Returns:
- the right tangent vector at the curve for position t
-
curvature
public double curvature(double t)
Description copied from interface:ContinuousCurve2DComputes the curvature at the given position. The curvature is finite for positionstthat correspond to smooth parts, and is infinite for singular points.- Specified by:
curvaturein interfaceContinuousCurve2D- Parameters:
t- the position on the curve- Returns:
- the curvature of the curve for position t
-
smoothPieces
public java.util.Collection<? extends LineSegment2D> smoothPieces()
Description copied from interface:CirculinearContinuousCurve2DReturns a set of circulinear elements, which are basis for circulinear curves.- Specified by:
smoothPiecesin interfaceCirculinearContinuousCurve2D- Specified by:
smoothPiecesin interfaceContinuousCurve2D
-
getT0
@Deprecated public double getT0()
Deprecated. replaced by t0() (since 0.11.1).
-
firstPoint
public Point2D firstPoint()
Returns the first point of the linear curve.- Specified by:
firstPointin interfaceCurve2D- Overrides:
firstPointin classAbstractContinuousCurve2D- Returns:
- the first point of the curve
- See Also:
Curve2D.t0(),Curve2D.point(double)
-
singularPoints
public java.util.Collection<Point2D> singularPoints()
Description copied from interface:Curve2DReturns a set of singular points, i. e. which do not locally admit derivative.- Specified by:
singularPointsin interfaceCurve2D- Returns:
- a collection of Point2D.
- See Also:
Curve2D.vertices()
-
isSingular
public boolean isSingular(double pos)
Description copied from interface:Curve2DChecks if a point is singular.- Specified by:
isSingularin interfaceCurve2D- Parameters:
pos- the position of the point on the curve- Returns:
- true if the point at this location is singular
-
position
public double position(Point2D point)
Description copied from interface:Curve2DComputes the position of the point on the curve. If the point does not belong to the curve, return Double.NaN. It is complementary to thepoint(double)method.- Specified by:
positionin interfaceCurve2D- Parameters:
point- a point belonging to the curve- Returns:
- the position of the point on the curve
- See Also:
Curve2D.point(double)
-
intersections
public java.util.Collection<Point2D> intersections(LinearShape2D line)
Description copied from interface:Curve2DReturns the intersection points of the curve with the specified line. The length of the result array is the number of intersection points.- Specified by:
intersectionsin interfaceCurve2D
-
continuousCurves
public java.util.Collection<? extends LinearCurve2D> 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 classAbstractContinuousCurve2D- Returns:
- a collection of continuous curves.
-
project
public double project(Point2D point)
Description copied from interface:Curve2DReturns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point. This function should always returns a valid value.
-
distance
public double distance(double x, double y)Description copied from interface:Shape2DReturns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.
-
distance
public double distance(Point2D point)
Description copied from interface:Shape2DReturns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
-
isEmpty
public boolean isEmpty()
Returns true if the polyline does not contain any point.
-
isBounded
public boolean isBounded()
Always returns true, because a linear curve is always bounded.
-
boundingBox
public Box2D boundingBox()
Returns the bounding box of this linear curve.- Specified by:
boundingBoxin interfaceShape2D- Returns:
- the bounding box of the shape.
-
contains
public boolean contains(double x, double y)Description copied from interface:Shape2DChecks if the shape contains the planar point defined by (x,y).
-
contains
public boolean contains(Point2D point)
Description copied from interface:Shape2DChecks if the shape contains the given point.
-
clip
public CurveSet2D<? extends LinearCurve2D> clip(Box2D box)
Clips the polyline by a box. The result is an instance of CurveSet2D, which contains only instances of Polyline2D. If the polyline is not clipped, the result is an instance of CurveSet2D which contains 0 curves.- Specified by:
clipin interfaceCirculinearContinuousCurve2D- Specified by:
clipin interfaceCirculinearCurve2D- Specified by:
clipin interfaceContinuousCurve2D- Specified by:
clipin interfaceCurve2D- Specified by:
clipin interfaceContinuousOrientedCurve2D- Specified by:
clipin interfaceOrientedCurve2D- Specified by:
clipin interfaceShape2D- Parameters:
box- the clipping box- Returns:
- the clipped shape
-
asGeneralPath
public java.awt.geom.GeneralPath asGeneralPath()
Returns a general path iterator.
-
draw
public void draw(java.awt.Graphics2D g2)
Description copied from interface:Curve2DDraws the curve on the given Graphics2D object.
-
-
DMelt 3.0 © DataMelt by jWork.ORG