Class Box
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 BoxBox(float width, float height, float depth, Vector position)
Create a new 3D Box with specified width, height, depth, and locationBox(float width, float height, Vector position)
Create a new 2D Box with specified width, height, and locationBox(Box box)
Copy constructor for Box -
Method Summary
Modifier and Type Method Description boolean
contains(Box... box)
Check if Boxes are inside this Boxboolean
contains(Vector... position)
Check if this Box contains positionsboolean
equals(java.lang.Object box)
Check if another Box is equal to this Boxfloat
getDepth()
Get the depth of the Boxfloat
getDimensions(Axis axis)
Get the dimensions of the Box for a specific Axisfloat
getFaceArea(Side side)
Get the face area for a specified Sidefloat
getHeight()
Get the height of the BoxVector
getMaximum()
Get the maximum of the BoxVector
getMinimum()
Get the minimum of the BoxVector
getPosition()
Get the position of the Boxfloat
getSurfaceArea()
Get the surface area of the Boxfloat
getVolume()
Get the volume of the Boxfloat
getWidth()
Get the width of the Boxboolean
overlaps(Box... box)
Check if Boxes overlap this BoxBox
setDepth(float depth)
Set a new depth of the Box and recalculate its min and max in the z axisBox
setDimensions(Axis axis, float dimension)
Set the dimensions of the Box for a specific AxisBox
setDimensions(Vector dimensions)
Set the dimensions of the BoxBox
setHeight(float height)
Set a new height of the Box and recalculate its min and max in the y axisBox
setPosition(Vector position)
Set the position of the Box and recalculate its min and maxBox
setWidth(float width)
Set a new width of the Box and recalculate its min and max in the x axisjava.lang.String
toString()
Get the Box represented as a formatted StringMethods 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
Create a new 3D Box with specified width, height, depth, and location- Parameters:
width
- Width of the Boxheight
- Height of the Boxdepth
- Depth of the Boxposition
- Location of the Box's center
-
Box
Create a new 2D Box with specified width, height, and location- Parameters:
width
- Width of the Boxheight
- Height of the Boxposition
- Location of the Box's center
-
Box
Copy constructor for Box- Parameters:
box
- Box to copy
-
-
Method Details
-
setDimensions
Set the dimensions of the Box- Parameters:
dimensions
- Dimensions of the Box- Returns:
- This Box
-
setDimensions
Set the dimensions of the Box for a specific Axis- Parameters:
axis
- Axis to set dimension fordimension
- Dimension in grid units- Returns:
- This Box
-
getDimensions
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
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
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
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
Get the position of the Box- Returns:
- Box position
-
setPosition
Set the position of the Box and recalculate its min and max- Parameters:
position
- New position- Returns:
- This Box
-
getMinimum
Get the minimum of the Box- Returns:
- Minimum location
-
getMaximum
Get the maximum of the Box- Returns:
- Maximum location
-
overlaps
Check if Boxes overlap this Box- Parameters:
box
- Boxes to check for overlap- Returns:
- True if the Boxes overlap this Box
-
contains
Check if Boxes are inside this Box- Parameters:
box
- Boxes to check- Returns:
- True if the Boxes are inside this Box
-
contains
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
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 classjava.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 classjava.lang.Object
- Parameters:
box
- Box to check for equality- Returns:
- True if the two Boxes are equal
-