Class Polygon2D


  • public class Polygon2D
    extends java.lang.Object
    Represents a convex 2D polygon, which may be degenerate (1-gon or 2-gon). The polygon keeps its vertices in clockwise order, and returns its vertices, edges and inequalities in clockwise order. The degenerate 1-gon has only one vertex and no edges. The degenerate 2-gon has two vertices and two edges.
    • Constructor Detail

      • Polygon2D

        public Polygon2D​(java.util.List<Point2D> vertices)
      • Polygon2D

        public Polygon2D​(Point2D point)
    • Method Detail

      • of

        public static Polygon2D of​(double... pointCoords)
      • getVertices

        public java.util.List<Point2D> getVertices()
      • getInequalities

        public java.util.List<Inequality2D> getInequalities()
      • calculateInequality

        public static Inequality2D calculateInequality​(LineSegment2D lineSegment,
                                                       Point2D pointInHalfPlane)
        Calculate the linear inequality representing the half plane defined by the given line and the given point.
      • contains

        public boolean contains​(Point2D p)
      • getRandomPointInside

        public Point2D getRandomPointInside()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object