Class Box


  • public class Box
    extends java.lang.Object
    An axis-aligned 3D box represented by its center and half-extent. The half-extent is a vector representing the distance from the center to the edge of the box in each dimension. For example, a box of size 2 units in X, 4 units in Y, and 10 units in Z would have a half-extent of (1, 2, 5).
    • Constructor Summary

      Constructors 
      Constructor Description
      Box()
      Default-initializes the 3D box to have a center and half-extent of (0,0,0).
      Box​(float[] center, float[] halfExtent)
      Initializes the 3D box from its center and half-extent.
      Box​(float centerX, float centerY, float centerZ, float halfExtentX, float halfExtentY, float halfExtentZ)
      Initializes the 3D box from its center and half-extent.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float[] getCenter()
      Returns the center of the 3D box.
      float[] getHalfExtent()
      Returns the half-extent from the center of the 3D box.
      void setCenter​(float centerX, float centerY, float centerZ)
      Sets the center of of the 3D box.
      void setHalfExtent​(float halfExtentX, float halfExtentY, float halfExtentZ)
      Sets the half-extent of the 3D box.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Box

        public Box()
        Default-initializes the 3D box to have a center and half-extent of (0,0,0).
      • Box

        public Box​(float centerX,
                   float centerY,
                   float centerZ,
                   float halfExtentX,
                   float halfExtentY,
                   float halfExtentZ)
        Initializes the 3D box from its center and half-extent.
      • Box

        public Box​(@NonNull @Size(min=3L)
                   float[] center,
                   @NonNull @Size(min=3L)
                   float[] halfExtent)
        Initializes the 3D box from its center and half-extent.
        Parameters:
        center - a float array with XYZ coordinates representing the center of the box
        halfExtent - a float array with XYZ coordinates representing half the size of the box in each dimension
    • Method Detail

      • setCenter

        public void setCenter​(float centerX,
                              float centerY,
                              float centerZ)
        Sets the center of of the 3D box.
      • setHalfExtent

        public void setHalfExtent​(float halfExtentX,
                                  float halfExtentY,
                                  float halfExtentZ)
        Sets the half-extent of the 3D box.
      • getCenter

        @NonNull
        @Size(min=3L)
        public float[] getCenter()
        Returns the center of the 3D box.
        Returns:
        an XYZ float array of size 3
      • getHalfExtent

        @NonNull
        @Size(min=3L)
        public float[] getHalfExtent()
        Returns the half-extent from the center of the 3D box.
        Returns:
        an XYZ float array of size 3