math.geom2d.polygon
Class LinearRing2D

Package class diagram package LinearRing2D
java.lang.Object
  extended by math.geom2d.curve.AbstractContinuousCurve2D
      extended by math.geom2d.polygon.Polyline2D
          extended by math.geom2d.polygon.LinearRing2D
All Implemented Interfaces:
Serializable, Cloneable, CirculinearBoundary2D, CirculinearContinuousCurve2D, CirculinearContour2D, CirculinearCurve2D, CirculinearShape2D, ContinuousCirculinearCurve2D, ContinuousCurve2D, Curve2D, Boundary2D, ContinuousBoundary2D, ContinuousOrientedCurve2D, OrientedCurve2D, Shape2D
Direct Known Subclasses:
Ring2D

public class LinearRing2D
extends Polyline2D
implements CirculinearContour2D

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:

Author:
dlegland
See Also:
Serialized Form

Field Summary
 
Fields inherited from class math.geom2d.polygon.Polyline2D
points
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY
 
Constructor Summary
LinearRing2D()
           
LinearRing2D(Collection<? extends Point2D> points)
           
LinearRing2D(double[] xcoords, double[] ycoords)
           
LinearRing2D(Point2D initialPoint)
           
LinearRing2D(Point2D[] points)
           
 
Method Summary
 GeneralPath appendPath(GeneralPath path)
          Append the path of the curve to the given path.
 LinearRing2D clone()
          Overrides Object declaration to ensure Curve2D implementation are cloned as Curve2D.
static LinearRing2D create(Collection<? extends Point2D> points)
          Static factory for creating a new LinearRing2D from a collection of points.
static LinearRing2D create(Point2D[] points)
          Static factory for creating a new LinearRing2D from an array of points.
 boolean equals(Object object)
           
 void fill(Graphics2D g2)
           
 double getArea()
          Computes area of the polyline, by returning the absolute value of the signed area.
 Collection<ContinuousBoundary2D> getBoundaryCurves()
          Returns the different continuous curves composing the boundary
 Collection<? extends LinearRing2D> getContinuousCurves()
          Returns the collection of continuous curves which constitute this curve.
 Domain2D getDomain()
          Returns the domain delimited by this boundary.
 Collection<LineSegment2D> getEdges()
          Returns an array of LineSegment2D.
 Point2D getFirstPoint()
          return the first point of the polyline.
 GeneralPath getGeneralPath()
          Return a general path iterator.
 LineSegment2D getLastEdge()
           
 Point2D getLastPoint()
          return the first point, as this is the same as the last point.
 CirculinearRing2D getParallel(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.
 Point2D getPoint(double t)
          Returns point from position as double.
 LinearRing2D getReverseCurve()
          Returns the closed polyline with same points taken in reverse order.
 double getSignedArea()
          Computes the signed area of the polyline.
 double getSignedDistance(double x, double y)
          The same as getSignedDistance(Point2D), but by passing 2 double as arguments.
 double getSignedDistance(Point2D point)
          Get the signed distance of the curve to the given point: this distance is positive if the point lies outside the shape, and is negative if the point lies inside the shape.
 Polyline2D getSubCurve(double t0, double t1)
          Return an instance of Polyline2D.
 double getT0()
          returns 0.
 double getT1()
          return the number of points in the polyline.
 double getWindingAngle(Point2D point)
          Return the angle portion that the curve turn around the given point.
 boolean isClosed()
          return true, by definition.
 boolean isInside(double x, double y)
           
 boolean isInside(Point2D point)
          Returns true if the point is 'inside' the domain bounded by the curve.
 LinearRing2D transform(AffineTransform2D trans)
          Return the transformed shape, as a ClosePolyline2D.
 CirculinearContour2D transform(CircleInversion2D inv)
          Transforms the shape by a circle inversion.
 
Methods inherited from class math.geom2d.polygon.Polyline2D
addPoint, clearPoints, clearVertices, clip, contains, contains, getBoundingBox, getBuffer, getDistance, getDistance, getEdge, getFirstEdge, getIntersections, getLeftTangent, getLength, getLength, getPointArray, getPointsIterator, getPosition, getPosition, getRightTangent, getSingularPoints, getSmoothPieces, getVertex, getVertexNumber, getVertices, isBounded, isEmpty, isSingular, project, removePoint
 
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D
draw, getAsAWTShape, getAsPolyline, wrapCurve
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface math.geom2d.circulinear.CirculinearContinuousCurve2D
clip, getSmoothPieces
 
Methods inherited from interface math.geom2d.circulinear.CirculinearCurve2D
getLength, getLength, getPosition
 
Methods inherited from interface math.geom2d.circulinear.CirculinearShape2D
getBuffer
 
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
getAsPolyline, getLeftTangent, getRightTangent
 
Methods inherited from interface math.geom2d.curve.Curve2D
draw, getAsAWTShape, getIntersections, getPosition, getSingularPoints, isSingular, project
 
Methods inherited from interface math.geom2d.Shape2D
contains, contains, getBoundingBox, getDistance, getDistance, isBounded, isEmpty
 
Methods inherited from interface math.geom2d.circulinear.CirculinearBoundary2D
clip
 

Constructor Detail

LinearRing2D

public LinearRing2D()

LinearRing2D

public LinearRing2D(Point2D initialPoint)

LinearRing2D

public LinearRing2D(Point2D[] points)

LinearRing2D

public LinearRing2D(double[] xcoords,
                    double[] ycoords)

LinearRing2D

public LinearRing2D(Collection<? extends Point2D> points)
Method Detail

create

public static LinearRing2D create(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[] points)
Static factory for creating a new LinearRing2D from an array of points.

Since:
0.8.1

getArea

public double getArea()
Computes area of the polyline, by returning the absolute value of the signed area.


getSignedArea

public double getSignedArea()
Computes the signed area of the polyline. 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.

getEdges

public Collection<LineSegment2D> getEdges()
Returns an array of LineSegment2D. The number of edges is the same as the number of vertices.

Overrides:
getEdges in class Polyline2D
Returns:
the edges of the polyline

getLastEdge

public LineSegment2D getLastEdge()
Overrides:
getLastEdge in class Polyline2D

getParallel

public CirculinearRing2D getParallel(double dist)
Description copied from interface: CirculinearCurve2D
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.

Specified by:
getParallel in interface CirculinearContinuousCurve2D
Specified by:
getParallel in interface CirculinearContour2D
Specified by:
getParallel in interface CirculinearCurve2D
Specified by:
getParallel in interface ContinuousCirculinearCurve2D
Overrides:
getParallel in class Polyline2D
Parameters:
dist - the distance between the original curve and he parallel curve.
Returns:
the parallel curve

transform

public CirculinearContour2D transform(CircleInversion2D inv)
Description copied from interface: CirculinearShape2D
Transforms the shape by a circle inversion. The result is still an instance a CirculinearShape2D.

Specified by:
transform in interface CirculinearBoundary2D
Specified by:
transform in interface CirculinearContinuousCurve2D
Specified by:
transform in interface CirculinearContour2D
Specified by:
transform in interface CirculinearCurve2D
Specified by:
transform in interface CirculinearShape2D
Specified by:
transform in interface ContinuousCirculinearCurve2D
Overrides:
transform in class Polyline2D
Parameters:
inv - the circle inversion
Returns:
the transformed shape

getBoundaryCurves

public Collection<ContinuousBoundary2D> getBoundaryCurves()
Description copied from interface: Boundary2D
Returns the different continuous curves composing the boundary

Specified by:
getBoundaryCurves in interface Boundary2D

getDomain

public Domain2D getDomain()
Description copied from interface: Boundary2D
Returns the domain delimited by this boundary.

Specified by:
getDomain in interface Boundary2D
Returns:
the domain delimited by this boundary

fill

public void fill(Graphics2D g2)
Specified by:
fill in interface Boundary2D

getSignedDistance

public double getSignedDistance(double x,
                                double y)
Description copied from interface: OrientedCurve2D
The same as getSignedDistance(Point2D), but by passing 2 double as arguments.

Specified by:
getSignedDistance in interface OrientedCurve2D
Overrides:
getSignedDistance in class Polyline2D
Parameters:
x - x-coord of a point
y - y-coord of a point
Returns:
the signed distance of the point (x,y) to the curve

getSignedDistance

public double getSignedDistance(Point2D point)
Description copied from interface: OrientedCurve2D
Get the signed distance of the curve to the given point: this distance is positive if the point lies outside the shape, and is negative if the point lies inside the shape. In this case, absolute value of distance is equals to the distance to the border of the shape.

Specified by:
getSignedDistance in interface OrientedCurve2D
Overrides:
getSignedDistance in class Polyline2D
Parameters:
point - a point of the plane
Returns:
the signed distance to the curve

getWindingAngle

public double getWindingAngle(Point2D point)
Description copied from interface: OrientedCurve2D
Return the angle portion that the curve turn around the given point. Result is a signed angle.

Specified by:
getWindingAngle in interface OrientedCurve2D
Overrides:
getWindingAngle in class Polyline2D
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: OrientedCurve2D
Returns true if the point is 'inside' the domain bounded by the curve.

Specified by:
isInside in interface Boundary2D
Specified by:
isInside in interface OrientedCurve2D
Overrides:
isInside in class Polyline2D
Parameters:
point - a point in the plane
Returns:
true if the point is on the left side of the curve.

isClosed

public boolean isClosed()
return true, by definition.

Specified by:
isClosed in interface ContinuousCurve2D
Overrides:
isClosed in class Polyline2D

getPoint

public Point2D getPoint(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 polyline.

Specified by:
getPoint in interface Curve2D
Overrides:
getPoint in class Polyline2D

getT0

public double getT0()
returns 0.

Specified by:
getT0 in interface Curve2D
Overrides:
getT0 in class Polyline2D

getT1

public double getT1()
return the number of points in the polyline.

Specified by:
getT1 in interface Curve2D
Overrides:
getT1 in class Polyline2D

getFirstPoint

public Point2D getFirstPoint()
return the first point of the polyline.

Specified by:
getFirstPoint in interface Curve2D
Overrides:
getFirstPoint in class Polyline2D
Returns:
the first point of the curve

getLastPoint

public Point2D getLastPoint()
return the first point, as this is the same as the last point.

Specified by:
getLastPoint in interface Curve2D
Overrides:
getLastPoint in class Polyline2D
Returns:
the last point of the curve.

getContinuousCurves

public Collection<? extends LinearRing2D> getContinuousCurves()
Description copied from interface: Curve2D
Returns the collection of continuous curves which constitute this curve.

Specified by:
getContinuousCurves in interface CirculinearBoundary2D
Specified by:
getContinuousCurves in interface CirculinearCurve2D
Specified by:
getContinuousCurves in interface Curve2D
Overrides:
getContinuousCurves in class Polyline2D
Returns:
a collection of continuous curves.

getReverseCurve

public LinearRing2D getReverseCurve()
Returns the closed polyline 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 pointers).

Specified by:
getReverseCurve in interface CirculinearBoundary2D
Specified by:
getReverseCurve in interface CirculinearContinuousCurve2D
Specified by:
getReverseCurve in interface CirculinearContour2D
Specified by:
getReverseCurve in interface CirculinearCurve2D
Specified by:
getReverseCurve in interface ContinuousCirculinearCurve2D
Specified by:
getReverseCurve in interface ContinuousCurve2D
Specified by:
getReverseCurve in interface Curve2D
Specified by:
getReverseCurve in interface Boundary2D
Specified by:
getReverseCurve in interface ContinuousBoundary2D
Specified by:
getReverseCurve in interface ContinuousOrientedCurve2D
Specified by:
getReverseCurve in interface OrientedCurve2D
Overrides:
getReverseCurve in class Polyline2D

getSubCurve

public Polyline2D getSubCurve(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:
getSubCurve in interface CirculinearContinuousCurve2D
Specified by:
getSubCurve in interface CirculinearCurve2D
Specified by:
getSubCurve in interface ContinuousCirculinearCurve2D
Specified by:
getSubCurve in interface ContinuousCurve2D
Specified by:
getSubCurve in interface Curve2D
Specified by:
getSubCurve in interface ContinuousOrientedCurve2D
Overrides:
getSubCurve in class Polyline2D
Parameters:
t0 - position of the start of the sub-curve
t1 - 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)
Return the transformed shape, as a ClosePolyline2D.

Specified by:
transform in interface ContinuousCurve2D
Specified by:
transform in interface Curve2D
Specified by:
transform in interface Boundary2D
Specified by:
transform in interface ContinuousBoundary2D
Specified by:
transform in interface ContinuousOrientedCurve2D
Specified by:
transform in interface OrientedCurve2D
Specified by:
transform in interface Shape2D
Overrides:
transform in class Polyline2D
Parameters:
trans - an affine transform
Returns:
the transformed shape

appendPath

public GeneralPath appendPath(GeneralPath path)
Description copied from interface: ContinuousCurve2D
Append the path of the curve to the given path.

Specified by:
appendPath in interface ContinuousCurve2D
Overrides:
appendPath in class Polyline2D
Parameters:
path - a path to modify
Returns:
the modified path

getGeneralPath

public GeneralPath getGeneralPath()
Return a general path iterator.

Overrides:
getGeneralPath in class Polyline2D

equals

public boolean equals(Object object)
Overrides:
equals in class Polyline2D

clone

public LinearRing2D clone()
Description copied from interface: Curve2D
Overrides Object declaration to ensure Curve2D implementation are cloned as Curve2D.

Specified by:
clone in interface Curve2D
Overrides:
clone in class Polyline2D
Returns:
the cloned curve


Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.