Package nl.colorize.multimedialib.math
Record Class Sphere
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.math.Sphere
- All Implemented Interfaces:
Shape3D
Immutable three-dimensional sphere with float precision. The sphere is
defined based on the location of its center point and its radius.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncenter()Returns the value of thecenterrecord component.booleanfinal booleanIndicates whether some other object is "equal to" this one.Returns the smallest possible bounding box that can fit this shape.final inthashCode()Returns a hash code value for this object.floatradius()Returns the value of theradiusrecord component.reposition(Point3D offset) Returns a newShape3Dinstance that is repositioned by the specified offset.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Sphere
Creates an instance of aSphererecord class.- Parameters:
center- the value for thecenterrecord componentradius- the value for theradiusrecord component
-
Sphere
public Sphere(float radius) Creates a sphere with its center point located at the origin (0, 0, 0).
-
-
Method Details
-
getBoundingBox
Description copied from interface:Shape3DReturns the smallest possible bounding box that can fit this shape.- Specified by:
getBoundingBoxin interfaceShape3D
-
getCenter
-
contains
-
reposition
Description copied from interface:Shape3DReturns a newShape3Dinstance that is repositioned by the specified offset.- Specified by:
repositionin interfaceShape3D
-
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
-