org.osm2world.core.math
public class PolygonXZ extends Object implements PolygonShapeXZ
Modifier and Type | Field and Description |
---|---|
protected List<VectorXZ> |
vertexLoop
polygon vertices; first and last vertex are equal
|
Modifier and Type | Method and Description |
---|---|
protected static void |
assertLoopProperty(List<VectorXZ> vertexLoop)
checks that the first and last vertex of the vertex list are equal.
|
SimplePolygonXZ |
asSimplePolygon()
returns a polygon with the coordinates of this polygon
that is an instance of
SimplePolygonXZ . |
TriangleXZ |
asTriangleXZ()
returns a triangle with the same vertices as this polygon.
|
VectorXZ |
getCenter()
returns the average of all vertex coordinates.
|
LineSegmentXZ |
getClosestSegment(VectorXZ point)
returns the polygon segment with minimum distance to a given point
|
double |
getOutlineLength()
returns the length of the polygon's outline.
|
List<LineSegmentXZ> |
getSegments() |
VectorXZ |
getVertex(int index)
returns the vertex at a position in the vertex sequence
|
VectorXZ |
getVertexAfter(int index)
returns the successor of the vertex at a position in the vertex sequence.
|
VectorXZ |
getVertexBefore(int index)
returns the predecessor of the vertex at a position in the vertex sequence.
|
List<VectorXZ> |
getVertexCollection()
returns a collection that contains all vertices of this polygon
at least once.
|
List<VectorXZ> |
getVertexList()
returns the polygon's vertices.
|
List<VectorXZ> |
getVertexLoop()
Deprecated.
Use the equivalent
getVertexList() instead. |
List<VectorXZ> |
getVertices()
returns the polygon's vertices.
|
List<VectorXZ> |
intersectionPositions(LineSegmentXZ lineSegment) |
Collection<LineSegmentXZ> |
intersectionSegments(LineSegmentXZ lineSegment) |
boolean |
intersects(LineSegmentXZ lineSegment) |
boolean |
intersects(PolygonXZ outlinePolygonXZ)
returns true if there is an intersection between this polygon's
and the parameter polygon's sides
|
boolean |
intersects(VectorXZ segmentP1,
VectorXZ segmentP2)
returns true if there is an intersection between this polygon
and the line segment defined by the parameter
|
boolean |
isEquivalentTo(PolygonXZ other)
returns true if the other polygon has the same vertices in the same order,
possibly with a different start vertex
|
boolean |
isSelfIntersecting()
returns whether this polygon is self-intersecting
|
static boolean |
isSelfIntersecting(List<VectorXZ> polygonVertexLoop)
returns true if the polygon defined by the polygonVertexLoop parameter
is self-intersecting.
The Code is based on Shamos-Hoey's algorithm TODO: if the end vertex of two line segments are the same the polygon is never considered as self intersecting on purpose. |
boolean |
isSimple()
checks whether this polygon is simple
|
PolygonXZ |
reverse() |
int |
size()
returns the number of vertices in this polygon.
|
String |
toString() |
PolygonXYZ |
xyz(double y) |
protected final List<VectorXZ> vertexLoop
public PolygonXZ(List<VectorXZ> vertexLoop)
vertexLoop
- vertices defining the polygon;
first and last vertex must be equalInvalidGeometryException
- if the polygon is self-intersecting
or produces invalid area calculation resultspublic int size()
getVertices()
.size().public List<VectorXZ> getVertices()
getVertexList()
, there is no duplication
of the first/last vertex.public List<VectorXZ> getVertexList()
getVertexList
in interface ShapeXZ
public List<VectorXZ> getVertexLoop()
getVertexList()
instead.public List<VectorXZ> getVertexCollection()
public VectorXZ getVertex(int index)
public VectorXZ getVertexAfter(int index)
public VectorXZ getVertexBefore(int index)
public List<LineSegmentXZ> getSegments()
public LineSegmentXZ getClosestSegment(VectorXZ point)
public boolean intersects(VectorXZ segmentP1, VectorXZ segmentP2)
public boolean intersects(LineSegmentXZ lineSegment)
public boolean intersects(PolygonXZ outlinePolygonXZ)
public Collection<LineSegmentXZ> intersectionSegments(LineSegmentXZ lineSegment)
public List<VectorXZ> intersectionPositions(LineSegmentXZ lineSegment)
public boolean isSelfIntersecting()
public static boolean isSelfIntersecting(List<VectorXZ> polygonVertexLoop)
public boolean isSimple()
public SimplePolygonXZ asSimplePolygon()
SimplePolygonXZ
.
Only works if it actually isSimple()
!public TriangleXZ asTriangleXZ()
public PolygonXYZ xyz(double y)
public PolygonXZ reverse()
public VectorXZ getCenter()
public double getOutlineLength()
public boolean isEquivalentTo(PolygonXZ other)
protected static void assertLoopProperty(List<VectorXZ> vertexLoop)
IllegalArgumentException
- if first and last vertex aren't equal
(this is usually a programming error,
therefore InvalidGeometryException is not used)public String toString()
toString
in class Object