Package de.ellpeck.rockbottom.api.util
Class BoundingBox
java.lang.Object
de.ellpeck.rockbottom.api.util.BoundingBox
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd(double x, double y) booleancontains(double x, double y) copy()static BoundingBoxempty()booleanexpand(double amount) expand(double x, double y) doublegetArea()doublegetBoundEdge(Direction direction) Gets the position of an edge based on the direction.doubledoublestatic BoundingBoxgetCombinedBoundBox(List<BoundingBox> boxes) doublegetIntersection(BoundingBox other) doublegetMaxX()doublegetMaxY()doublegetMinX()doublegetMinY()getUnion(BoundingBox other) doublegetWidth()inthashCode()booleanintersects(double minX, double minY, double maxX, double maxY) booleanintersects(BoundingBox other) booleanisEmpty()set(double minX, double minY, double maxX, double maxY) set(BoundingBox box) toString()
-
Constructor Details
-
BoundingBox
public BoundingBox() -
BoundingBox
public BoundingBox(double minX, double minY, double maxX, double maxY)
-
-
Method Details
-
empty
-
getCombinedBoundBox
-
set
-
set
-
add
-
expand
-
expand
-
intersects
-
intersects
public boolean intersects(double minX, double minY, double maxX, double maxY) -
contains
public boolean contains(double x, double y) -
getIntersection
-
getUnion
-
isEmpty
public boolean isEmpty() -
getBoundEdge
Gets the position of an edge based on the direction. For example: box = BoundBox(-2.8, 0.2, 10.2, 11.5) box.getBoundEdge(Direction.UP) is 11.5. box.getBoundEdge(Direction.LEFT) is -2.8.- Parameters:
direction- The (CARDINAL) direction towards the edge- Returns:
- The position value at that edge if direction is cardinal, 0 otherwise.
-
equals
-
hashCode
public int hashCode() -
toString
-
getMinX
public double getMinX() -
getMinY
public double getMinY() -
getMaxX
public double getMaxX() -
getMaxY
public double getMaxY() -
getWidth
public double getWidth() -
getHeight
public double getHeight() -
getArea
public double getArea() -
getCenterX
public double getCenterX() -
getCenterY
public double getCenterY() -
copy
-