Interface Polygon2d

All Superinterfaces:
Iterable<Vector2d>
All Known Subinterfaces:
MPolygon2d, MRectangle2d, MTriangle2d, Rectangle2d, Triangle2d

public interface Polygon2d extends Iterable<Vector2d>
Read-only interface for handling simple polygons without holes in the XY-plane.
Since:
9.10.2
  • Method Details

    • contains

      boolean contains(Polygon2d polygon)
      Returns true if the given polygon is inside this polygon.
      Parameters:
      polygon - the polygon that is checked for containment inside this polygon
      Returns:
      true if the given polygon is inside this polygon
      Since:
      9.10.2
    • contains

      boolean contains(Vector2d point)
      Returns true if the given point is inside this polygon.
      Parameters:
      point - the point that is checked for containment inside this polygon
      Returns:
      true if the given point is inside this polygon
      Since:
      9.10.2
    • distance

      default double distance(Polygon2d polygon)
      Returns the minimum distance between this polygon and the given polygon.
      Parameters:
      polygon - the polygon to which the distance is computed
      Returns:
      the distance between this polygon and the given polygon
      Since:
      9.10.2
    • distance

      default double distance(Segment2d segment)
      Returns the minimum distance between this polygon and the given segment. If the segment intersects this polygon, then returns zero.
      Parameters:
      segment - the segment to which the distance is computed
      Returns:
      the minimum distance between this polygon and the given segment
      Since:
      9.10.2
    • distance

      default double distance(Vector2d point)
      Returns the distance between this polygon and the given point.
      Parameters:
      point - the point to which the distance is computed
      Returns:
      the distance between this polygon and the given point
      Since:
      9.10.2
    • distanceSquared

      double distanceSquared(Polygon2d polygon)
      Returns the square of the distance between this polygon and the given polygon.
      Parameters:
      polygon - the polygon to which the squared distance is computed
      Returns:
      the square of the distance between this polygon and the given polygon
      Since:
      9.10.2
    • distanceSquared

      double distanceSquared(Segment2d segment)
      Returns the square of the minimum distance between this polygon and the given segment. If the segment intersects this polygon, then returns zero.
      Parameters:
      segment - the segment to which the squared distance is computed
      Returns:
      the square of the minimum distance between this polygon and the given segment
      Since:
      9.10.2
    • distanceSquared

      double distanceSquared(Vector2d point)
      Returns the square of the distance between this polygon and the given point.
      Parameters:
      point - the point to which the squared distance is computed
      Returns:
      the square of the distance between this polygon and the given point
      Since:
      9.10.2
    • getArea

      double getArea()
      Returns the area of this polygon.
      Returns:
      the area of this polygon
      Since:
      9.10.2
    • getCentroid

      MVector2d getCentroid()
      Returns the centroid of this polygon. The centroid is the center of mass.
      Returns:
      the centroid of this polygon
      Since:
      9.10.2
    • getBoundingRectangle

      MAABB2d getBoundingRectangle()
      Returns a copy of the minimum area axis aligned bounding rectangle.
      Returns:
      bounding rectangle whose lower and upper points are the lower and upper points from the bounding rectangle
      Since:
      9.10.2
    • getOrientedBoundingRectangle

      MRectangle2d getOrientedBoundingRectangle()
      Returns the minimum area oriented bounding rectangle for this polygon.
      Returns:
      the minimum area oriented bounding rectangle for this polygon
      Since:
      9.10.2
    • getEdgeIterator

      Iterator<Segment2d> getEdgeIterator()
      Returns an iterator that iterates through the edges of this polygon.
      Returns:
      an iterator that iterates through the edges of this polygon
      Since:
      9.10.2
    • getPerimeter

      double getPerimeter()
      Returns the perimeter length of this polygon.
      Returns:
      the perimeter length of this polygon
      Since:
      9.10.2
    • intersectEdges

      Collection<MVector2d> intersectEdges(Segment2d segment)
      Returns all intersection points between the edges of this polygon and the given segment. If this segment and the polygon do not intersect, then returns an empty collection.
      Parameters:
      segment - the segment with which the intersections are computed
      Returns:
      all intersection points between the edges of this polygon and the given segment
      Since:
      9.10.2
    • shortestSegmentTo

      Segment2d shortestSegmentTo(Polygon2d polygon)
      Returns the shortest segment between this polygon and the given polygon. The start point of the segment is in this polygon and the end point is in the given polygon. If the polygons intersect, then the segment is of zero length.
      Parameters:
      polygon - the polygon to which the shortest distance segment is returned
      Returns:
      the shortest segment between this polygon and the given polygon
      Since:
      9.10.2
    • getVertexCount

      int getVertexCount()
      Returns the number of vertices in this polygon.
      Returns:
      the number of vertices in this polygon
      Since:
      9.10.2
    • getVertices

      List<Vector2d> getVertices()
      Returns the vertices of this polygon.
      Returns:
      the vertices of this polygon
      Since:
      9.10.2
    • intersects

      boolean intersects(Polygon2d polygon)
      Returns true if this polygon intersects the given polygon.
      Parameters:
      polygon - the polygon that is checked for intersection with this polygon
      Returns:
      true if this polygon intersects the given polygon
      Since:
      9.10.2
    • isCounterClockwise

      boolean isCounterClockwise()
      Returns true if the vertices of this polygon are in counter clockwise order.
      Returns:
      true if the vertices of this polygon are in counter clockwise order
      Since:
      9.10.2
    • isConvex

      boolean isConvex()
      Returns true if this polygon is convex.
      Returns:
      true if this polygon is convex
      Since:
      9.10.2
    • toArea

      MArea toArea()
      Returns this polygon as an MArea object.
      Returns:
      this polygon as an MArea object
      Since:
      9.10.2
    • create

      static Polygon2d create(List<? extends Vector2d> vertices)
      Creates a 2-dimensional polygon with the given vertices. The returned polygon does not take ownership of the given vertices.
      Parameters:
      vertices - the vertices used for creating the returned polygon
      Returns:
      a polygon with the given vertices
      Since:
      9.10.2
    • create

      static Polygon2d create(Polygon2d polygon)
      Creates a 2-dimensional polygon with the contents deep copied from the given polygon. The returned polygon does not take ownership of the given polygon.
      Parameters:
      polygon - the polygon whose contents are deep copied into the returned polygon
      Returns:
      a polygon with the contents deep copied from the given polygon
      Since:
      9.10.2