Class JavaPolygon2D

    • Constructor Detail

      • JavaPolygon2D

        protected JavaPolygon2D()
      • JavaPolygon2D

        public JavaPolygon2D​(JavaPoint2D... points)
    • Method Detail

      • getPolygonFromUnsortedPointCloud

        public static JavaPolygon2D getPolygonFromUnsortedPointCloud​(JavaPoint2D... javaPoint2Ds)
        Sorts the given point cloud
        Parameters:
        javaPoint2Ds - the point cloud
        Returns:
        the java polygon with the point cloud sorted.
      • getIntersection

        public static JavaPolygon2D getIntersection​(JavaPolygon2D jp1,
                                                    JavaPolygon2D jp2)
        Method for getting the intersection polygon of two polygons
        Parameters:
        jp1 - polygon 1 (must be sorted!)
        jp2 - polygon 2 (must be sorted!)
        Returns:
        The intersection area as new JavaPolygon. Which is empty if given polygons are not sorted, are empty or there is no intersection area.
        See Also:
        Based on swtestacademy
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • isInConvexHull

        public boolean isInConvexHull​(JavaPoint2D point)
        Method which checks if point is within the convex hull
        Parameters:
        point - Point which should be checked
        Returns:
        True if point is in convex hull else False
      • isInConvexHull

        public boolean isInConvexHull​(JavaPoint2D point,
                                      boolean considerPointsOnHull)
        Method which checks if point is part of the convex hull if considerPointsOnHull flag is false only points within the hull are allowed else points can also be on the hull lines
        Parameters:
        point - Point which should be checked
        considerPointsOnHull - if the function should return true if the point is on the convex hull.
        Returns:
        True if point is in convex hull else False
      • sort

        public JavaPolygon2D sort()
        Sorts the points in the java polygon and returns a new sorted java polygon
        Returns:
        the java polygon with the point cloud sorted.