Package org.pepsoft.util
Class Box
java.lang.Object
org.pepsoft.util.Box
- All Implemented Interfaces:
Cloneable
A rectangular three dimensional volume, defined by two corners, the corner
with the lowest x, y and z coordinates being inclusive and the opposite
corner being exclusive.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()booleancontains(int x, int y, int z) booleancontainsXY(int x, int y) voidExtends this box so that it encompasses the other boxvoidexpand(int delta) Expand the box by a particular amount in every direction.intGet the size of the box along the Z axis.intGet the size of the box along the Y axis.intGet the total surface area of the box.intGet the volume of the box.intgetWidth()Get the size of the box along the X axis.intgetX1()intgetX2()intgetY1()intgetY2()intgetZ1()intgetZ2()voidSets this box to the intersection of it and the specified box; in other words to the volume encompassed by both boxes.booleanisEmpty()voidsetX1(int x1) voidsetX2(int x2) voidsetY1(int y1) voidsetY2(int y2) voidsetZ1(int z1) voidsetZ2(int z2) toString()voidtranslate(int dx, int dy, int dz)
-
Constructor Details
-
Box
public Box() -
Box
public Box(int x1, int x2, int y1, int y2, int z1, int z2)
-
-
Method Details
-
getX1
public int getX1() -
setX1
public void setX1(int x1) -
getX2
public int getX2() -
setX2
public void setX2(int x2) -
getY1
public int getY1() -
setY1
public void setY1(int y1) -
getY2
public int getY2() -
setY2
public void setY2(int y2) -
getZ1
public int getZ1() -
setZ1
public void setZ1(int z1) -
getZ2
public int getZ2() -
setZ2
public void setZ2(int z2) -
getWidth
public int getWidth()Get the size of the box along the X axis.- Returns:
- The size of the box along the X axis.
-
getLength
public int getLength()Get the size of the box along the Y axis.- Returns:
- The size of the box along the Y axis.
-
getHeight
public int getHeight()Get the size of the box along the Z axis.- Returns:
- The size of the box along the Z axis.
-
getVolume
public int getVolume()Get the volume of the box.- Returns:
- The volume of the box.
-
getSurface
public int getSurface()Get the total surface area of the box.- Returns:
- The total surface area of the box.
-
translate
public void translate(int dx, int dy, int dz) -
encompass
Extends this box so that it encompasses the other box- Parameters:
box- The box to encompass.
-
intersect
Sets this box to the intersection of it and the specified box; in other words to the volume encompassed by both boxes.If the boxes don't intersect, the x2, y2 and z2 coordinates of this box will be made equal to the x1, y1 and z1 coordinates so that it becomes empty.
- Parameters:
box- The box to intersect this box with.
-
isEmpty
public boolean isEmpty() -
contains
public boolean contains(int x, int y, int z) -
containsXY
public boolean containsXY(int x, int y) -
getFootPrint
-
expand
public void expand(int delta) Expand the box by a particular amount in every direction.- Parameters:
delta- The delta by which to move every face of the box outwards.
-
toString
-
clone
-