Class PolygonUtils


  • public class PolygonUtils
    extends Object
    Helper class for polygons.
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Constructor Detail

      • PolygonUtils

        public PolygonUtils()
    • Method Detail

      • toPolygon

        public static Polygon toPolygon​(List<Point> points)
        Returns the bounding box for the polygon.
        Parameters:
        points - the polygon points to calculate the bounding box for
        Returns:
        the polygon
      • toPolygon

        public static Polygon toPolygon​(Rectangle rect)
        Turns the rectangle into a polygon.
        Parameters:
        rect - the polygon to convert
        Returns:
        the polygon
      • toPoints

        public static List<Point> toPoints​(Polygon poly)
        Turns the polygon into a list of points.
        Parameters:
        poly - the polygon
        Returns:
        the list of points
      • boundingBox

        public static Rectangle boundingBox​(List<Point> points)
        Returns the bounding box for the polygon.
        Parameters:
        points - the polygon points to calculate the bounding box for
        Returns:
        the bbox
      • minDistance

        public static double minDistance​(Point A,
                                         Point B,
                                         Point E)
        Returns the minimum distance between a line segment AB and a point E.
        Parameters:
        A - the start of the line segment
        B - the end of the line segment
        E - the point to calculate the min distance to
        Returns:
        the minimum distance
      • addVertext

        public static Polygon addVertext​(Polygon poly,
                                         Point vertex)
        Adds the vertex to the polygon at the appropriate position.
        Parameters:
        poly - the polygon to add to
        vertex - the vertex to insert
        Returns:
        the new polygon