Package nl.colorize.multimedialib.math
Record Class Box
java.lang.Object
java.lang.Record
nl.colorize.multimedialib.math.Box
- All Implemented Interfaces:
Shape3D
public record Box(float x, float y, float z, float width, float height, float depth)
extends Record
implements Shape3D
Immutable three-dimensional box with float precision. The box is specified
based on the position of its top-left corner and its size.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBox(float x, float y, float z, float width, float height, float depth) Creates an instance of aBoxrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic BoxFactory method that creates a box based on the location of its center point.static BoxaroundOrigin(float width, float height, float depth) Factory method that creates a box with its center point located at the origin (0, 0, 0).Returns a new box that encompasses both this box and the specified other box.booleanReturns true if the specified other box is entirely or partially located within this box.booleanReturns true if the specified point is located within this box.floatdepth()Returns the value of thedepthrecord component.final booleanIndicates whether some other object is "equal to" this one.static BoxfromPoints(float x0, float y0, float z0, float x1, float y1, float z1) Factory method that creates a box based on the points (x0, y0, z0) and (x1, y1, z1).Returns the smallest possible bounding box that can fit this shape.floatgetEndX()floatgetEndY()floatgetEndZ()final inthashCode()Returns a hash code value for this object.floatheight()Returns the value of theheightrecord component.booleanintersects(Box other) Returns true if the specified other box intersects with this box.reposition(Point3D offset) Returns a newShape3Dinstance that is repositioned by the specified offset.toString()Returns a string representation of this record class.floatwidth()Returns the value of thewidthrecord component.floatx()Returns the value of thexrecord component.floaty()Returns the value of theyrecord component.floatz()Returns the value of thezrecord component.
-
Constructor Details
-
Box
public Box(float x, float y, float z, float width, float height, float depth) Creates an instance of aBoxrecord class.- Parameters:
x- the value for thexrecord componenty- the value for theyrecord componentz- the value for thezrecord componentwidth- the value for thewidthrecord componentheight- the value for theheightrecord componentdepth- the value for thedepthrecord component
-
-
Method Details
-
getEndX
public float getEndX() -
getEndY
public float getEndY() -
getEndZ
public float getEndZ() -
getBoundingBox
Description copied from interface:Shape3DReturns the smallest possible bounding box that can fit this shape.- Specified by:
getBoundingBoxin interfaceShape3D
-
getCenter
-
contains
Returns true if the specified point is located within this box. -
contains
Returns true if the specified other box is entirely or partially located within this box. -
intersects
Returns true if the specified other box intersects with this box. -
reposition
Description copied from interface:Shape3DReturns a newShape3Dinstance that is repositioned by the specified offset.- Specified by:
repositionin interfaceShape3D
-
combine
Returns a new box that encompasses both this box and the specified other box. -
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 box based on the points (x0, y0, z0) and (x1, y1, z1). -
around
Factory method that creates a box based on the location of its center point. -
aroundOrigin
Factory method that creates a box with its center point located at the origin (0, 0, 0). -
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 with '=='. -
x
public float x()Returns the value of thexrecord component.- Returns:
- the value of the
xrecord component
-
y
public float y()Returns the value of theyrecord component.- Returns:
- the value of the
yrecord component
-
z
public float z()Returns the value of thezrecord component.- Returns:
- the value of the
zrecord component
-
width
public float width()Returns the value of thewidthrecord component.- Returns:
- the value of the
widthrecord component
-
height
public float height()Returns the value of theheightrecord component.- Returns:
- the value of the
heightrecord component
-
depth
public float depth()Returns the value of thedepthrecord component.- Returns:
- the value of the
depthrecord component
-