Package nl.colorize.multimedialib.math
Record Class Polygon
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.math.Polygon
- All Implemented Interfaces:
Shape
A two-dimensional convex polygon with float precision coordinates.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether this shape contains the specified point.static PolygoncreateCircle(Point2D origin, float radius, int numPoints) Convenience method to create a polygon in the shape of a circle with the specified properties.static PolygoncreateCone(Point2D origin, float angle, float arc, float length) Convenience method to create a cone-shaped polygon.static PolygoncreateCone(Point2D origin, Angle angle, float arc, float length) Convenience method to create a cone-shaped polygon.final booleanIndicates whether some other object is "equal to" this one.static PolygonfromPoints(float... points) Factory method that creates a polygon from an array of points, in the format[x0, y0, x1, y1, ...].Returns the smallest possible axis-aligned rectangle that contains this polygon.intDeprecated.getPoint(int n) Deprecated.floatgetPointX(int n) Deprecated.floatgetPointY(int n) Deprecated.final inthashCode()Returns a hash code value for this object.booleanReturns true if this polygon intersects with the specified other polygon.points()Returns the value of thepointsrecord component.reposition(Point2D offset) Returns a newShapeinstance that is repositioned by the specified offset.Subdivides this polygon into a number of triangles.float[]toPoints()Returns an array that contains the X and Y coordinates for all points within this polygon, in the format[x0, y0, x1, y1, ...].toString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface nl.colorize.multimedialib.math.Shape
reposition
-
Constructor Details
-
Polygon
Creates an instance of aPolygonrecord class.- Parameters:
points- the value for thepointsrecord component
-
-
Method Details
-
toPoints
public float[] toPoints()Returns an array that contains the X and Y coordinates for all points within this polygon, in the format[x0, y0, x1, y1, ...]. -
getNumPoints
Deprecated. -
getPointX
Deprecated. -
getPointY
Deprecated. -
getPoint
Deprecated. -
contains
Description copied from interface:ShapeReturns whether this shape contains the specified point. -
intersects
Returns true if this polygon intersects with the specified other polygon. Implementation based on Slick. -
getBoundingBox
Returns the smallest possible axis-aligned rectangle that contains this polygon.- Specified by:
getBoundingBoxin interfaceShape
-
getCenter
-
subdivide
Subdivides this polygon into a number of triangles. This requires this polygon to be convex. -
reposition
Description copied from interface:ShapeReturns a newShapeinstance that is repositioned by the specified offset.- Specified by:
repositionin interfaceShape
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
fromPoints
Factory method that creates a polygon from an array of points, in the format[x0, y0, x1, y1, ...]. -
createCircle
Convenience method to create a polygon in the shape of a circle with the specified properties. -
createCone
Convenience method to create a cone-shaped polygon. The cone's angle indicates in which direction the cone is pointed, its arc indicates its size (in degrees). -
createCone
Convenience method to create a cone-shaped polygon. The cone's angle indicates in which direction the cone is pointed, its arc indicates its size (in degrees). -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
points
Returns the value of thepointsrecord component.- Returns:
- the value of the
pointsrecord component
-