Class Polygon2d

    • Constructor Detail

      • Polygon2d

        public Polygon2d​(Point2d point1,
                         Point2d point2,
                         Point2d[] otherPoints)
                  throws DrawRuntimeException
        Construct a new Polygon2d.
        Parameters:
        point1 - Point2d; the first point of the new Polygon2d
        point2 - Point2d; the second point of the new Polygon2d
        otherPoints - Point2d[]; all remaining points of the new Polygon2d (may be null)
        Throws:
        DrawRuntimeException - when point2 is equal to the last point of otherPoints, or any two successive points are equal
    • Method Detail

      • contains

        public final boolean contains​(Point2d point)
        Determine if a point is inside this Polygon.
        Parameters:
        point - Point2d; the point
        Returns:
        boolean; true if the point is inside this polygon, false if the point is outside this polygon. Results are ill-defined for points on the edges of this Polygon.
      • difference

        public Polygon2d difference​(Polygon2d otherPolygon)
        Subtract the overlap with another Polygon2d from this Polygon2d and return the result as a new Polygon2d.
        Parameters:
        otherPolygon - Polygon2d; the other Polygon2d
        Returns:
        Polygon2d; the asymmetrical difference; or null if there otherPolygon completely covers this Polygon2d