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
-
Method Summary
Modifier and TypeMethodDescriptionfloat
calculateDistance
(Circle other) Returns the distance between the center of this circle and the center of the specified other circle.float
Returns the distance between the center of this circle and the specified point.center()
Returns the value of thecenter
record component.boolean
Returns whether this shape contains the specified point.final boolean
Indicates whether some other object is "equal to" this one.Returns the smallest possible rectangular bounding box that can fit this shape.final int
hashCode()
Returns a hash code value for this object.boolean
intersects
(Circle other) float
radius()
Returns the value of theradius
record component.reposition
(Point2D offset) Returns a newShape
instance that is repositioned by the specified X and Y offset.toString()
Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface nl.colorize.multimedialib.math.Shape
reposition
-
Constructor Details
-
Circle
Creates an instance of aCircle
record class.- Parameters:
center
- the value for thecenter
record componentradius
- the value for theradius
record component
-
Circle
public Circle(float x, float y, float radius)
-
-
Method Details
-
contains
Description copied from interface:Shape
Returns 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:Shape
Returns the smallest possible rectangular bounding box that can fit this shape.- Specified by:
getBoundingBox
in interfaceShape
-
reposition
Description copied from interface:Shape
Returns a newShape
instance that is repositioned by the specified X and Y offset.- Specified by:
reposition
in 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 thecenter
record component.- Returns:
- the value of the
center
record component
-
radius
public float radius()Returns the value of theradius
record component.- Returns:
- the value of the
radius
record component
-