Class ConvexPolygon2D
java.lang.Object
org.episteme.core.mathematics.geometry.boundaries.ConvexPolygon2D
- All Implemented Interfaces:
Serializable, Boundary<Point2D>, Boundary2D
A convex polygon in 2D space.
This is the simplest form of 2D boundary - a convex polygon defined by its vertices in counter-clockwise order.
- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConvexPolygon2D(List<Point2D> vertices) Creates a convex polygon from vertices.ConvexPolygon2D(Point2D... vertices) Creates a convex polygon from vertex array. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if a point is contained within this boundary.Computes the convex hull of this boundary.booleanCreates an extruded 3D boundary from this 2D boundary.static ConvexPolygon2DfromPoints(List<Point2D> points) Creates a convex polygon from a set of points by computing their convex hull.getArea()Returns the area of this 2D boundary.Returns the bounding box of this boundary.Returns the centroid of this boundary.Returns the perimeter of this 2D boundary.getVertex(int index) Returns a specific vertex.intReturns the number of vertices.Returns the vertices of this boundary in order.inthashCode()intersection(Boundary<Point2D> other) Computes the intersection of this boundary with another.booleanintersects(Boundary<Point2D> other) Checks if this boundary intersects with another.booleanisConvex()Checks if this boundary is convex.booleanisEmpty()Checks if this boundary is empty.static ConvexPolygon2DCreates a rectangle.static ConvexPolygon2DCreates a regular polygon.Rotates the boundary around the centroid.rotateAround(Real angleRadians, Point2D pivot) Rotates around a specific pivot point.Creates a scaled copy of this boundary.toString()Creates a copy of this boundary translated by a vector.static ConvexPolygon2DCreates a triangle.Computes the union of this boundary with another.Methods inherited from interface Boundary2D
getBoundaryMeasure, getDimension, getMeasure
-
Constructor Details
-
ConvexPolygon2D
-
ConvexPolygon2D
Creates a convex polygon from vertex array.- Parameters:
vertices- the vertices
-
-
Method Details
-
fromPoints
Creates a convex polygon from a set of points by computing their convex hull.- Parameters:
points- the input points- Returns:
- the convex polygon
-
regular
Creates a regular polygon.- Parameters:
center- the center pointradius- distance from center to verticessides- number of sides (minimum 3)- Returns:
- regular polygon
-
triangle
Creates a triangle. -
rectangle
Creates a rectangle. -
getVertices
Description copied from interface:Boundary2DReturns the vertices of this boundary in order.- Specified by:
getVerticesin interfaceBoundary2D- Returns:
- list of vertices
-
getVertexCount
public int getVertexCount()Description copied from interface:Boundary2DReturns the number of vertices.- Specified by:
getVertexCountin interfaceBoundary2D- Returns:
- vertex count
-
getVertex
Description copied from interface:Boundary2DReturns a specific vertex.- Specified by:
getVertexin interfaceBoundary2D- Parameters:
index- the vertex index- Returns:
- the vertex
-
getArea
Description copied from interface:Boundary2DReturns the area of this 2D boundary.- Specified by:
getAreain interfaceBoundary2D- Returns:
- the area
-
getPerimeter
Description copied from interface:Boundary2DReturns the perimeter of this 2D boundary.- Specified by:
getPerimeterin interfaceBoundary2D- Returns:
- the perimeter
-
isConvex
public boolean isConvex()Description copied from interface:Boundary2DChecks if this boundary is convex.- Specified by:
isConvexin interfaceBoundary2D- Returns:
- true if convex
-
isEmpty
-
getCentroid
Description copied from interface:BoundaryReturns the centroid of this boundary.- Specified by:
getCentroidin interfaceBoundary<Point2D>- Returns:
- the geometric center
-
getBoundingBox
Description copied from interface:BoundaryReturns the bounding box of this boundary.- Specified by:
getBoundingBoxin interfaceBoundary<Point2D>- Returns:
- an axis-aligned bounding box
-
contains
-
intersects
-
union
-
intersection
-
convexHull
-
translate
-
scale
-
rotate
Description copied from interface:Boundary2DRotates the boundary around the centroid.- Specified by:
rotatein interfaceBoundary2D- Parameters:
angleRadians- rotation angle in radians- Returns:
- rotated boundary
-
rotateAround
Description copied from interface:Boundary2DRotates around a specific pivot point.- Specified by:
rotateAroundin interfaceBoundary2D- Parameters:
angleRadians- rotation anglepivot- the pivot point- Returns:
- rotated boundary
-
extrude
Description copied from interface:Boundary2DCreates an extruded 3D boundary from this 2D boundary.- Specified by:
extrudein interfaceBoundary2D- Parameters:
height- the extrusion height- Returns:
- a 3D boundary
-
equals
-
hashCode
-
toString
-