Package org.seamcat.model.geometry
Class Polygon2D
- java.lang.Object
-
- org.seamcat.model.geometry.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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Inequality2D
calculateInequality(LineSegment2D lineSegment, Point2D pointInHalfPlane)
Calculate the linear inequality representing the half plane defined by the given line and the given point.Point2D
center()
boolean
contains(Point2D p)
java.util.List<LineSegment2D>
getEdges()
java.util.List<Inequality2D>
getInequalities()
Point2D
getRandomPointInside()
java.util.List<Point2D>
getVertices()
static Polygon2D
of(double... pointCoords)
java.lang.String
toString()
Polygon2D
translate(Vector2D v)
-
-
-
Method Detail
-
of
public static Polygon2D of(double... pointCoords)
-
getVertices
public java.util.List<Point2D> getVertices()
-
getEdges
public java.util.List<LineSegment2D> getEdges()
-
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)
-
center
public Point2D center()
-
getRandomPointInside
public Point2D getRandomPointInside()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-