org.osm2world.core.math
Class SimplePolygonXZ

Object
  extended by PolygonXZ
      extended by SimplePolygonXZ

public class SimplePolygonXZ
extends PolygonXZ

a non-self-intersecting polygon in the XZ plane


Field Summary
 
Fields inherited from class PolygonXZ
vertexLoop
 
Constructor Summary
SimplePolygonXZ(List<VectorXZ> vertexLoop)
           
 
Method Summary
 PolygonWithHolesXZ asPolygonWithHolesXZ()
           
 SimplePolygonXZ asSimplePolygon()
          returns a polygon with the coordinates of this polygon that is an instance of SimplePolygonXZ.
static boolean contains(List<VectorXZ> polygonVertexLoop, VectorXZ test)
          returns true if the polygon defined by the polygonVertexLoop parameter contains a given position
 boolean contains(PolygonXZ p)
          returns true if this polygon contains the parameter polygon
 boolean contains(VectorXZ test)
          returns true if the polygon contains a given position
 double distanceToSegments(VectorXZ p)
          returns the distance of a point to the segments this polygon.
 double getArea()
          returns the polygon's area
 VectorXZ getCentroid()
          returns the centroid (or "barycenter") of the polygon
 double getDiameter()
          returns the largest distance between any pair of vertices of this polygon
 List<LineSegmentXZ> getSegments()
           
 SimplePolygonXZ getSimplifiedPolygon()
          returns a different polygon that is constructed from this polygon by removing all vertices where this has an angle close to 180° (i.e.
 boolean isClockwise()
          returns true if the polygon has clockwise orientation
 boolean isSelfIntersecting()
          returns whether this polygon is self-intersecting
 boolean isSimple()
          checks whether this polygon is simple
 SimplePolygonXZ makeClockwise()
          returns this polygon if it is counterclockwise, or the reversed polygon if it is clockwise.
 SimplePolygonXZ makeCounterclockwise()
          returns this polygon if it is clockwise, or the reversed polygon if it is counterclockwise.
 SimplePolygonXZ reverse()
           
 SimplePolygonXZ shift(VectorXZ shiftVector)
          creates a new polygon by adding a shift vector to each vector of this
 
Methods inherited from class PolygonXZ
assertLoopProperty, asTriangleXZ, getCenter, getClosestSegment, getOutlineLength, getVertex, getVertexAfter, getVertexBefore, getVertexCollection, getVertexLoop, getVertices, intersectionPositions, intersectionSegments, intersects, intersects, intersects, isEquivalentTo, isSelfIntersecting, size, toString, xyz
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimplePolygonXZ

public SimplePolygonXZ(List<VectorXZ> vertexLoop)
Parameters:
vertexLoop - vertices defining the polygon; first and last vertex must be equal
Throws:
InvalidGeometryException - if the polygon is self-intersecting or produces invalid area calculation results
Method Detail

getSegments

public List<LineSegmentXZ> getSegments()
Overrides:
getSegments in class PolygonXZ

getArea

public double getArea()
returns the polygon's area


getCentroid

public VectorXZ getCentroid()
returns the centroid (or "barycenter") of the polygon


getDiameter

public double getDiameter()
returns the largest distance between any pair of vertices of this polygon


isClockwise

public boolean isClockwise()
returns true if the polygon has clockwise orientation


isSelfIntersecting

public boolean isSelfIntersecting()
Description copied from class: PolygonXZ
returns whether this polygon is self-intersecting

Overrides:
isSelfIntersecting in class PolygonXZ

isSimple

public boolean isSimple()
Description copied from class: PolygonXZ
checks whether this polygon is simple

Overrides:
isSimple in class PolygonXZ

asSimplePolygon

public SimplePolygonXZ asSimplePolygon()
Description copied from class: PolygonXZ
returns a polygon with the coordinates of this polygon that is an instance of SimplePolygonXZ. Only works if it actually PolygonXZ.isSimple()!

Overrides:
asSimplePolygon in class PolygonXZ

asPolygonWithHolesXZ

public PolygonWithHolesXZ asPolygonWithHolesXZ()
Returns:
a PolygonWithHolesXZ with this polygon as the outer polygon and no holes

makeClockwise

public SimplePolygonXZ makeClockwise()
returns this polygon if it is counterclockwise, or the reversed polygon if it is clockwise.


makeCounterclockwise

public SimplePolygonXZ makeCounterclockwise()
returns this polygon if it is clockwise, or the reversed polygon if it is counterclockwise.


reverse

public SimplePolygonXZ reverse()
Overrides:
reverse in class PolygonXZ

shift

public SimplePolygonXZ shift(VectorXZ shiftVector)
creates a new polygon by adding a shift vector to each vector of this


contains

public static boolean contains(List<VectorXZ> polygonVertexLoop,
                               VectorXZ test)
returns true if the polygon defined by the polygonVertexLoop parameter contains a given position


contains

public boolean contains(VectorXZ test)
returns true if the polygon contains a given position


contains

public boolean contains(PolygonXZ p)
returns true if this polygon contains the parameter polygon


distanceToSegments

public double distanceToSegments(VectorXZ p)
returns the distance of a point to the segments this polygon. Note that the distance can be > 0 even if the polygon contains the point


getSimplifiedPolygon

public SimplePolygonXZ getSimplifiedPolygon()
returns a different polygon that is constructed from this polygon by removing all vertices where this has an angle close to 180° (i.e. where removing the vertex does not change the polygon very much).