Package com.solibri.geometry.primitive2d
Interface Polygon2d
- All Known Subinterfaces:
MPolygon2d
,MRectangle2d
,MTriangle2d
,Rectangle2d
,Triangle2d
Read-only interface for handling simple polygons without holes in the
XY-plane.
- Since:
- 9.10.2
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns true if the given point is inside this polygon.boolean
Returns true if the given polygon is inside this polygon.static Polygon2d
Creates a 2-dimensional polygon with the contents deep copied from the given polygon.static Polygon2d
Creates a 2-dimensional polygon with the given vertices.default double
Returns the distance between this polygon and the given point.default double
Returns the minimum distance between this polygon and the given polygon.default double
Returns the minimum distance between this polygon and the given segment.double
distanceSquared
(Vector2d point) Returns the square of the distance between this polygon and the given point.double
distanceSquared
(Polygon2d polygon) Returns the square of the distance between this polygon and the given polygon.double
distanceSquared
(Segment2d segment) Returns the square of the minimum distance between this polygon and the given segment.double
getArea()
Returns the area of this polygon.Returns a copy of the minimum area axis aligned bounding rectangle.Returns the centroid of this polygon.Returns an iterator that iterates through the edges of this polygon.Returns the minimum area oriented bounding rectangle for this polygon.double
Returns the perimeter length of this polygon.int
Returns the number of vertices in this polygon.Returns the vertices of this polygon.intersectEdges
(Segment2d segment) Returns all intersection points between the edges of this polygon and the given segment.boolean
intersects
(Polygon2d polygon) Returns true if this polygon intersects the given polygon.boolean
isConvex()
Returns true if this polygon is convex.boolean
Returns true if the vertices of this polygon are in counter clockwise order.shortestSegmentTo
(Polygon2d polygon) Returns the shortest segment between this polygon and the given polygon.toArea()
Returns this polygon as anMArea
object.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
contains
Returns true if the given polygon is inside this polygon.- Parameters:
polygon
- the polygon that is checked for containment inside this polygon- Returns:
- true if the given polygon is inside this polygon
- Since:
- 9.10.2
-
contains
Returns true if the given point is inside this polygon.- Parameters:
point
- the point that is checked for containment inside this polygon- Returns:
- true if the given point is inside this polygon
- Since:
- 9.10.2
-
distance
Returns the minimum distance between this polygon and the given polygon.- Parameters:
polygon
- the polygon to which the distance is computed- Returns:
- the distance between this polygon and the given polygon
- Since:
- 9.10.2
-
distance
Returns the minimum distance between this polygon and the given segment. If the segment intersects this polygon, then returns zero.- Parameters:
segment
- the segment to which the distance is computed- Returns:
- the minimum distance between this polygon and the given segment
- Since:
- 9.10.2
-
distance
Returns the distance between this polygon and the given point.- Parameters:
point
- the point to which the distance is computed- Returns:
- the distance between this polygon and the given point
- Since:
- 9.10.2
-
distanceSquared
Returns the square of the distance between this polygon and the given polygon.- Parameters:
polygon
- the polygon to which the squared distance is computed- Returns:
- the square of the distance between this polygon and the given polygon
- Since:
- 9.10.2
-
distanceSquared
Returns the square of the minimum distance between this polygon and the given segment. If the segment intersects this polygon, then returns zero.- Parameters:
segment
- the segment to which the squared distance is computed- Returns:
- the square of the minimum distance between this polygon and the given segment
- Since:
- 9.10.2
-
distanceSquared
Returns the square of the distance between this polygon and the given point.- Parameters:
point
- the point to which the squared distance is computed- Returns:
- the square of the distance between this polygon and the given point
- Since:
- 9.10.2
-
getArea
double getArea()Returns the area of this polygon.- Returns:
- the area of this polygon
- Since:
- 9.10.2
-
getCentroid
MVector2d getCentroid()Returns the centroid of this polygon. The centroid is the center of mass.- Returns:
- the centroid of this polygon
- Since:
- 9.10.2
-
getBoundingRectangle
MAABB2d getBoundingRectangle()Returns a copy of the minimum area axis aligned bounding rectangle.- Returns:
- bounding rectangle whose lower and upper points are the lower and upper points from the bounding rectangle
- Since:
- 9.10.2
-
getOrientedBoundingRectangle
MRectangle2d getOrientedBoundingRectangle()Returns the minimum area oriented bounding rectangle for this polygon.- Returns:
- the minimum area oriented bounding rectangle for this polygon
- Since:
- 9.10.2
-
getEdgeIterator
Returns an iterator that iterates through the edges of this polygon.- Returns:
- an iterator that iterates through the edges of this polygon
- Since:
- 9.10.2
-
getPerimeter
double getPerimeter()Returns the perimeter length of this polygon.- Returns:
- the perimeter length of this polygon
- Since:
- 9.10.2
-
intersectEdges
Returns all intersection points between the edges of this polygon and the given segment. If this segment and the polygon do not intersect, then returns an empty collection.- Parameters:
segment
- the segment with which the intersections are computed- Returns:
- all intersection points between the edges of this polygon and the given segment
- Since:
- 9.10.2
-
shortestSegmentTo
Returns the shortest segment between this polygon and the given polygon. The start point of the segment is in this polygon and the end point is in the given polygon. If the polygons intersect, then the segment is of zero length.- Parameters:
polygon
- the polygon to which the shortest distance segment is returned- Returns:
- the shortest segment between this polygon and the given polygon
- Since:
- 9.10.2
-
getVertexCount
int getVertexCount()Returns the number of vertices in this polygon.- Returns:
- the number of vertices in this polygon
- Since:
- 9.10.2
-
getVertices
Returns the vertices of this polygon.- Returns:
- the vertices of this polygon
- Since:
- 9.10.2
-
intersects
Returns true if this polygon intersects the given polygon.- Parameters:
polygon
- the polygon that is checked for intersection with this polygon- Returns:
- true if this polygon intersects the given polygon
- Since:
- 9.10.2
-
isCounterClockwise
boolean isCounterClockwise()Returns true if the vertices of this polygon are in counter clockwise order.- Returns:
- true if the vertices of this polygon are in counter clockwise order
- Since:
- 9.10.2
-
isConvex
boolean isConvex()Returns true if this polygon is convex.- Returns:
- true if this polygon is convex
- Since:
- 9.10.2
-
toArea
MArea toArea()Returns this polygon as anMArea
object.- Returns:
- this polygon as an
MArea
object - Since:
- 9.10.2
-
create
Creates a 2-dimensional polygon with the given vertices. The returned polygon does not take ownership of the given vertices.- Parameters:
vertices
- the vertices used for creating the returned polygon- Returns:
- a polygon with the given vertices
- Since:
- 9.10.2
-
create
Creates a 2-dimensional polygon with the contents deep copied from the given polygon. The returned polygon does not take ownership of the given polygon.- Parameters:
polygon
- the polygon whose contents are deep copied into the returned polygon- Returns:
- a polygon with the contents deep copied from the given polygon
- Since:
- 9.10.2
-