|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcs2110.collision.BoundingBox
public class BoundingBox
An instance is a 2D bounding box.
Field Summary | |
---|---|
Vector2D |
lower
The corner of the bounding box with the smaller x,y coordinates. |
Vector2D |
upper
The corner of the bounding box with the larger x,y coordinates. |
Constructor Summary | |
---|---|
BoundingBox(BoundingBox b)
Constructor: an instance is a copy of bounding box b. |
|
BoundingBox(Vector2D lower,
Vector2D upper)
Constructor: An instance with lower as smaller coordinates and upper as larger coordinates. |
Method Summary | |
---|---|
boolean |
contains(Vector2D p)
Return true iff this bounding box contains p. |
BoundingBox |
displaced(Vector2D d)
Return the result of displacing this bounding box by d. |
static BoundingBox |
findBBox(java.util.Iterator<Block> iter)
Return the bounding box of blocks given by iter. |
double |
getArea()
Return the area of this bounding box. |
Vector2D |
getCenter()
Return the center of this bounding box. |
double |
getHeight()
Return the height of this bounding box (along y-dimension). |
double |
getLength()
Return the larger of the width and height of this bounding box. |
double |
getWidth()
Return the width of this bounding box (along x-dimension). |
boolean |
overlaps(BoundingBox box)
Return true iff this bounding box overlaps with box. |
java.lang.String |
toString()
Return a representation of this bounding box. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public Vector2D lower
public Vector2D upper
Constructor Detail |
---|
public BoundingBox(BoundingBox b)
public BoundingBox(Vector2D lower, Vector2D upper)
lower
- Corner with smaller coordinates.upper
- Corner with larger coordinates.Method Detail |
---|
public double getWidth()
public double getHeight()
public double getLength()
public Vector2D getCenter()
public BoundingBox displaced(Vector2D d)
d
- A displacement vector.
public boolean contains(Vector2D p)
p
- A point.
public double getArea()
public boolean overlaps(BoundingBox box)
box
- A bounding box.
public static BoundingBox findBBox(java.util.Iterator<Block> iter)
iter
- An iterator of blocks.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |