@NullMarked
public interface Shape
Shape is a common interface for geometric shapes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Vector2D
calculateCentroid
(Vector2D[] points) Calculates and returns the centroid of the shape represented by the array of points.boolean
Checks if this Shape contains a point.float
getArea()
Calculates the area of this shape and return it.default Vector2D
Calculates and returns the centroid of thisShape
.Vector2D[]
-
Method Details
-
contains
Checks if this Shape contains a point.- Parameters:
point
- the point to check- Returns:
- true if this shape contains the point
-
getPoints
Vector2D[] getPoints()- Returns:
- the array of points making up this shape
-
getArea
float getArea()Calculates the area of this shape and return it.- Returns:
- the area of this shape
-
getCentroid
Calculates and returns the centroid of thisShape
.- Returns:
- the centroid
-
calculateCentroid
Calculates and returns the centroid of the shape represented by the array of points.- Parameters:
points
- the points of the shape- Returns:
- the centroid
-