Package org.djutils.draw.surface
Class Polygon2d
- java.lang.Object
-
- org.djutils.draw.line.PolyLine2d
-
- org.djutils.draw.surface.Polygon2d
-
- All Implemented Interfaces:
Serializable
,Drawable<Point2d,Space2d>
,Drawable2d
,PolyLine<PolyLine2d,Point2d,Space2d,Ray2d>
public class Polygon2d extends PolyLine2d
Polygon2d.java. Closed PolyLine2d. The actual closing point (which is the same as the starting point) is NOT included in the super PolyLine2d.Copyright (c) 2020-2021 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.- Author:
- Alexander Verbraeck, Peter Knoppers
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.djutils.draw.line.PolyLine2d
DEFAULT_CIRCLE_PRECISION, DEFAULT_OFFSET_FILTER_RATIO, DEFAULT_OFFSET_MAXIMUM_FILTER_VALUE, DEFAULT_OFFSET_MINIMUM_FILTER_VALUE, DEFAULT_OFFSET_PRECISION
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Point2d point)
Determine if a point is inside this Polygon.Polygon2d
difference(Polygon2d otherPolygon)
Subtract the overlap with another Polygon2d from this Polygon2d and return the result as a new Polygon2d.-
Methods inherited from class org.djutils.draw.line.PolyLine2d
concatenate, concatenate, concatenate, createAndCleanPolyLine2d, createAndCleanPolyLine2d, equals, extract, get, getBounds, getLength, getLocation, getLocationExtended, getPoints, hashCode, instantiate, lengthAtIndex, noiseFilteredLine, offsetLine, offsetLine, projectOrthogonal, projectOrthogonal, projectRay, size, toExcel, toPlot, toString, truncate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.djutils.draw.line.PolyLine
extractFractional, find, getFirst, getLast, getLocationFraction, getLocationFraction, getLocationFractionExtended, reverse
-
-
-
-
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 Polygon2dpoint2
- Point2d; the second point of the new Polygon2dotherPoints
- 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
-
-