Package nl.colorize.multimedialib.math
Record Class Circle
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.math.Circle
- All Implemented Interfaces:
Shape
Circle that is defined by its center point and a radius. Circles are
immutable and are defined with float precision.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatcalculateDistance(Circle other) Returns the distance between the center of this circle and the center of the specified other circle.floatReturns the distance between the center of this circle and the specified point.center()Returns the value of thecenterrecord component.booleanReturns whether this shape contains the specified point.final booleanIndicates whether some other object is "equal to" this one.Returns the smallest possible rectangular bounding box that can fit this shape.final inthashCode()Returns a hash code value for this object.booleanintersects(Circle other) floatradius()Returns the value of theradiusrecord component.reposition(Point2D offset) Returns a newShapeinstance that is repositioned by the specified offset.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
-
Circle
Creates an instance of aCirclerecord class.- Parameters:
center- the value for thecenterrecord componentradius- the value for theradiusrecord component
-
Circle
public Circle(float x, float y, float radius) -
Circle
public Circle(float radius) Creates a circle with its center point located at the origin (0, 0).
-
-
Method Details
-
getCenter
-
contains
Description copied from interface:ShapeReturns whether this shape contains the specified point. -
intersects
-
calculateDistance
Returns the distance between the center of this circle and the specified point. -
calculateDistance
Returns the distance between the center of this circle and the center of the specified other circle. -
getBoundingBox
Description copied from interface:ShapeReturns the smallest possible rectangular bounding box that can fit this shape.- Specified by:
getBoundingBoxin interfaceShape
-
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. -
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
center
Returns the value of thecenterrecord component.- Returns:
- the value of the
centerrecord component
-
radius
public float radius()Returns the value of theradiusrecord component.- Returns:
- the value of the
radiusrecord component
-