math.geom2d.polygon
Class LinearRing2D
- java.lang.Object
-
- math.geom2d.curve.AbstractContinuousCurve2D
-
- math.geom2d.polygon.LinearCurve2D
-
- math.geom2d.polygon.LinearRing2D
-
- All Implemented Interfaces:
- java.lang.Cloneable, CirculinearBoundary2D, CirculinearContinuousCurve2D, CirculinearContour2D, CirculinearCurve2D, CirculinearRing2D, CirculinearShape2D, ContinuousCurve2D, Curve2D, Boundary2D, ContinuousOrientedCurve2D, Contour2D, OrientedCurve2D, GeometricObject2D, Shape2D
public class LinearRing2D extends LinearCurve2D implements CirculinearRing2D
A LinearRing2D is a Polyline2D whose last point is connected to the first one. This is typically the boundary of a SimplePolygon2D.
The name 'LinearRing2D' was used for 2 reasons:
- it is short
- it is consistent with the JTS name
-
-
Constructor Summary
Constructors Constructor and Description LinearRing2D()LinearRing2D(java.util.Collection<? extends Point2D> points)LinearRing2D(double[] xcoords, double[] ycoords)LinearRing2D(int n)LinearRing2D(LinearCurve2D lineString)LinearRing2D(Point2D... vertices)
-
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.doublearea()Computes the signed area of the linear ring.LinearRing2Dclone()Deprecated.use copy constructor instead (0.11.2)java.util.Collection<? extends LinearRing2D>continuousCurves()Returns the collection of continuous curves which constitute this curve.static LinearRing2Dcreate(java.util.Collection<? extends Point2D> points)Static factory for creating a new LinearRing2D from a collection of points.static LinearRing2Dcreate(Point2D... vertices)Static factory for creating a new LinearRing2D from an array of points.CirculinearDomain2Ddomain()Returns the domain delimited by this boundary.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)voidfill(java.awt.Graphics2D g2)Fills the interior of the boundary, using the Graphics current Paint.doublegetT1()Deprecated.replaced by t1() (since 0.11.1).booleanisClosed()Returns true, by definition of linear ring.booleanisInside(double x, double y)booleanisInside(Point2D point)Returns true if the point is 'inside' the domain bounded by the curve.LineSegment2DlastEdge()Returns the last edge of this linear ring.Point2DlastPoint()Returns the first point, as this is the same as the last point.CirculinearRing2Dparallel(double dist)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.Point2Dpoint(double t)Returns point from position as double.LinearRing2Dreverse()Returns the linear ring with same points taken in reverse order.LinearRing2Dsimplify(double distMax)Returns a simplified version of this linear ring, by using Douglas-Peucker algorithm.Polyline2DsubCurve(double t0, double t1)Return an instance of Polyline2D.doublet1()Returns the number of points in the linear ring.LinearRing2Dtransform(AffineTransform2D trans)Returns the transformed shape, as a LinerRing2D.CirculinearRing2Dtransform(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, asGeneralPath, boundingBox, buffer, clearVertices, clip, closestVertexIndex, contains, contains, curvature, distance, distance, draw, firstEdge, firstPoint, getT0, insertVertex, intersections, isBounded, isEmpty, isSingular, leftTangent, length, length, 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, smoothPieces
-
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
asPolyline, curvature, leftTangent, rightTangent
-
Methods inherited from interface math.geom2d.circulinear.CirculinearBoundary2D
clip
-
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.domain.OrientedCurve2D
signedDistance, signedDistance
-
-
-
-
Constructor Detail
-
LinearRing2D
public LinearRing2D()
-
LinearRing2D
public LinearRing2D(int n)
-
LinearRing2D
public LinearRing2D(Point2D... vertices)
-
LinearRing2D
public LinearRing2D(double[] xcoords, double[] ycoords)
-
LinearRing2D
public LinearRing2D(java.util.Collection<? extends Point2D> points)
-
LinearRing2D
public LinearRing2D(LinearCurve2D lineString)
-
-
Method Detail
-
create
public static LinearRing2D create(java.util.Collection<? extends Point2D> points)
Static factory for creating a new LinearRing2D from a collection of points.- Since:
- 0.8.1
-
create
public static LinearRing2D create(Point2D... vertices)
Static factory for creating a new LinearRing2D from an array of points.- Since:
- 0.8.1
-
area
public double area()
Computes the signed area of the linear ring. Algorithm is taken from page: http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/. Signed are is positive if polyline is oriented counter-clockwise, and negative otherwise. Result is wrong if polyline is self-intersecting.- Returns:
- the signed area of the polyline.
-
simplify
public LinearRing2D simplify(double distMax)
Returns a simplified version of this linear ring, 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 same as the number of vertices.- 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()
Returns the last edge of this linear ring. The last edge connects the last vertex with the first one.- Specified by:
lastEdgein classLinearCurve2D
-
parallel
public CirculinearRing2D parallel(double dist)
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 interfaceCirculinearBoundary2D- Specified by:
parallelin interfaceCirculinearContinuousCurve2D- Specified by:
parallelin interfaceCirculinearContour2D- Specified by:
parallelin interfaceCirculinearCurve2D- Specified by:
parallelin interfaceCirculinearRing2D- Overrides:
parallelin classLinearCurve2D- Parameters:
dist- the distance between the original curve and he parallel curve.- Returns:
- the parallel curve
-
transform
public CirculinearRing2D 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 interfaceCirculinearBoundary2D- Specified by:
transformin interfaceCirculinearContinuousCurve2D- Specified by:
transformin interfaceCirculinearContour2D- Specified by:
transformin interfaceCirculinearCurve2D- Specified by:
transformin interfaceCirculinearShape2D- Parameters:
inv- the circle inversion- Returns:
- the transformed shape
-
domain
public CirculinearDomain2D domain()
Description copied from interface:Boundary2DReturns the domain delimited by this boundary.- Specified by:
domainin interfaceCirculinearBoundary2D- Specified by:
domainin interfaceCirculinearRing2D- Specified by:
domainin interfaceBoundary2D- Returns:
- the domain delimited by this boundary
-
fill
public void fill(java.awt.Graphics2D g2)
Description copied from interface:Boundary2DFills the interior of the boundary, using the Graphics current Paint.- Specified by:
fillin interfaceBoundary2D- Parameters:
g2- the Graphics to fill on
-
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(double x, double y)
-
isInside
public boolean isInside(Point2D point)
Description copied from interface:Boundary2DReturns true if the point is 'inside' the domain bounded by the curve.- Specified by:
isInsidein interfaceBoundary2D- Specified by:
isInsidein interfaceOrientedCurve2D- Parameters:
point- a point in the plane- Returns:
- true if the point is on the left side of the curve.
-
isClosed
public boolean isClosed()
Returns true, by definition of linear ring.- Specified by:
isClosedin interfaceContinuousCurve2D
-
point
public Point2D point(double t)
Returns point from position as double. Position t can be from 0 to n, with n equal to the number of vertices of the linear ring.
-
t1
public double t1()
Returns the number of points in the linear ring.
-
getT1
@Deprecated public double getT1()
Deprecated. replaced by t1() (since 0.11.1).
-
lastPoint
public Point2D lastPoint()
Returns the first point, as this is the same as the last point.- Specified by:
lastPointin interfaceCurve2D- Overrides:
lastPointin classAbstractContinuousCurve2D- Returns:
- the last point of the curve.
- See Also:
Curve2D.t1(),Curve2D.point(double)
-
continuousCurves
public java.util.Collection<? extends LinearRing2D> continuousCurves()
Description copied from interface:Curve2DReturns the collection of continuous curves which constitute this curve.- Specified by:
continuousCurvesin interfaceCirculinearBoundary2D- Specified by:
continuousCurvesin interfaceCirculinearCurve2D- Specified by:
continuousCurvesin interfaceCurve2D- Specified by:
continuousCurvesin interfaceBoundary2D- Overrides:
continuousCurvesin classLinearCurve2D- Returns:
- a collection of continuous curves.
-
reverse
public LinearRing2D reverse()
Returns the linear ring with same points taken in reverse order. The first points is still the same. Points of reverse curve are the same as the original curve (same references).- Specified by:
reversein interfaceCirculinearBoundary2D- Specified by:
reversein interfaceCirculinearContinuousCurve2D- Specified by:
reversein interfaceCirculinearContour2D- Specified by:
reversein interfaceCirculinearCurve2D- Specified by:
reversein interfaceCirculinearRing2D- Specified by:
reversein interfaceContinuousCurve2D- Specified by:
reversein interfaceCurve2D- Specified by:
reversein interfaceBoundary2D- Specified by:
reversein interfaceContinuousOrientedCurve2D- Specified by:
reversein interfaceContour2D- Specified by:
reversein interfaceOrientedCurve2D
-
subCurve
public Polyline2D subCurve(double t0, double t1)
Return an instance of Polyline2D. If t1 is lower than t0, the returned Polyline contains the origin of the curve.- 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 LinearRing2D transform(AffineTransform2D trans)
Returns the transformed shape, as a LinerRing2D.- Specified by:
transformin interfaceContinuousCurve2D- Specified by:
transformin interfaceCurve2D- Specified by:
transformin interfaceBoundary2D- Specified by:
transformin interfaceContinuousOrientedCurve2D- Specified by:
transformin interfaceContour2D- 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
-
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 LinearRing2D clone()
Deprecated. use copy constructor instead (0.11.2)- Specified by:
clonein interfaceCurve2D- Specified by:
clonein classAbstractContinuousCurve2D
-
-
DMelt 3.0 © DataMelt by jWork.ORG