java.lang.Object
xyz.jeremynoesen.pseudo3d.core.util.Box
Direct Known Subclasses:
Physics

public class Box
extends java.lang.Object
Box and related mathematical operators
  • Constructor Summary

    Constructors
    Constructor Description
    Box()
    Create a new default Box
    Box​(float width, float height, float depth, Vector position)
    Create a new 3D Box with specified width, height, depth, and location
    Box​(float width, float height, Vector position)
    Create a new 2D Box with specified width, height, and location
    Box​(Box box)
    Copy constructor for Box
  • Method Summary

    Modifier and Type Method Description
    boolean contains​(Box... box)
    Check if Boxes are inside this Box
    boolean contains​(Vector... position)
    Check if this Box contains positions
    boolean equals​(java.lang.Object box)
    Check if another Box is equal to this Box
    float getDepth()
    Get the depth of the Box
    float getDimensions​(Axis axis)
    Get the dimensions of the Box for a specific Axis
    float getFaceArea​(Side side)
    Get the face area for a specified Side
    float getHeight()
    Get the height of the Box
    Vector getMaximum()
    Get the maximum of the Box
    Vector getMinimum()
    Get the minimum of the Box
    Vector getPosition()
    Get the position of the Box
    float getSurfaceArea()
    Get the surface area of the Box
    float getVolume()
    Get the volume of the Box
    float getWidth()
    Get the width of the Box
    boolean overlaps​(Box... box)
    Check if Boxes overlap this Box
    Box setDepth​(float depth)
    Set a new depth of the Box and recalculate its min and max in the z axis
    Box setDimensions​(Axis axis, float dimension)
    Set the dimensions of the Box for a specific Axis
    Box setDimensions​(Vector dimensions)
    Set the dimensions of the Box
    Box setHeight​(float height)
    Set a new height of the Box and recalculate its min and max in the y axis
    Box setPosition​(Vector position)
    Set the position of the Box and recalculate its min and max
    Box setWidth​(float width)
    Set a new width of the Box and recalculate its min and max in the x axis
    java.lang.String toString()
    Get the Box represented as a formatted String

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Box

      public Box()
      Create a new default Box
    • Box

      public Box​(float width, float height, float depth, Vector position)
      Create a new 3D Box with specified width, height, depth, and location
      Parameters:
      width - Width of the Box
      height - Height of the Box
      depth - Depth of the Box
      position - Location of the Box's center
    • Box

      public Box​(float width, float height, Vector position)
      Create a new 2D Box with specified width, height, and location
      Parameters:
      width - Width of the Box
      height - Height of the Box
      position - Location of the Box's center
    • Box

      public Box​(Box box)
      Copy constructor for Box
      Parameters:
      box - Box to copy
  • Method Details

    • setDimensions

      public Box setDimensions​(Vector dimensions)
      Set the dimensions of the Box
      Parameters:
      dimensions - Dimensions of the Box
      Returns:
      This Box
    • setDimensions

      public Box setDimensions​(Axis axis, float dimension)
      Set the dimensions of the Box for a specific Axis
      Parameters:
      axis - Axis to set dimension for
      dimension - Dimension in grid units
      Returns:
      This Box
    • getDimensions

      public float getDimensions​(Axis axis)
      Get the dimensions of the Box for a specific Axis
      Parameters:
      axis - Axis to get dimension for
      Returns:
      Dimension of the specified Axis
    • getWidth

      public float getWidth()
      Get the width of the Box
      Returns:
      Width of the Box
    • setWidth

      public Box setWidth​(float width)
      Set a new width of the Box and recalculate its min and max in the x axis
      Parameters:
      width - New width of Box
      Returns:
      This Box
    • getHeight

      public float getHeight()
      Get the height of the Box
      Returns:
      Height of the Box
    • setHeight

      public Box setHeight​(float height)
      Set a new height of the Box and recalculate its min and max in the y axis
      Parameters:
      height - New height of the Box
      Returns:
      This Box
    • getDepth

      public float getDepth()
      Get the depth of the Box
      Returns:
      Depth of Box
    • setDepth

      public Box setDepth​(float depth)
      Set a new depth of the Box and recalculate its min and max in the z axis
      Parameters:
      depth - New depth of the Box
      Returns:
      This Box
    • getPosition

      public Vector getPosition()
      Get the position of the Box
      Returns:
      Box position
    • setPosition

      public Box setPosition​(Vector position)
      Set the position of the Box and recalculate its min and max
      Parameters:
      position - New position
      Returns:
      This Box
    • getMinimum

      public Vector getMinimum()
      Get the minimum of the Box
      Returns:
      Minimum location
    • getMaximum

      public Vector getMaximum()
      Get the maximum of the Box
      Returns:
      Maximum location
    • overlaps

      public boolean overlaps​(Box... box)
      Check if Boxes overlap this Box
      Parameters:
      box - Boxes to check for overlap
      Returns:
      True if the Boxes overlap this Box
    • contains

      public boolean contains​(Box... box)
      Check if Boxes are inside this Box
      Parameters:
      box - Boxes to check
      Returns:
      True if the Boxes are inside this Box
    • contains

      public boolean contains​(Vector... position)
      Check if this Box contains positions
      Parameters:
      position - Positions to check
      Returns:
      True of the Box contains these positions
    • getVolume

      public float getVolume()
      Get the volume of the Box
      Returns:
      Volume of the Box
    • getSurfaceArea

      public float getSurfaceArea()
      Get the surface area of the Box
      Returns:
      Surface area of the Box
    • getFaceArea

      public float getFaceArea​(Side side)
      Get the face area for a specified Side
      Parameters:
      side - Side to get face area for
      Returns:
      Face area of the Side
    • toString

      public java.lang.String toString()
      Get the Box represented as a formatted String
      Overrides:
      toString in class java.lang.Object
      Returns:
      Box in string format
    • equals

      public boolean equals​(java.lang.Object box)
      Check if another Box is equal to this Box
      Overrides:
      equals in class java.lang.Object
      Parameters:
      box - Box to check for equality
      Returns:
      True if the two Boxes are equal