cs2110.collision
Class BlockTree
java.lang.Object
cs2110.collision.BlockTree
public class BlockTree
- extends Object
A non-empty collection of points organized in a hierarchical binary tree
structure.
BlockTree
public BlockTree(ArrayList<Block> blocks)
- Construct a binary tree containing blocks. The tree has no be non-empty,
i.e., it must contain at least one block.
- Parameters:
blocks
-
getBox
public cs2110.collision.BoundingBox getBox()
- Returns:
- The bounding box of this collection of blocks.
isLeaf
public boolean isLeaf()
- Returns:
- True iff this is a leaf node.
isIntermediate
public boolean isIntermediate()
- Returns:
- True iff this is an intermediate node.
getNumBlocks
public int getNumBlocks()
- Returns:
- Number of blocks contained in tree.
contains
public boolean contains(cs2110.collision.Vector2D p)
- Parameters:
p
- A point.
- Returns:
- True iff this collection of blocks contains the point p.
overlaps
public boolean overlaps(cs2110.collision.Vector2D thisD,
BlockTree t,
cs2110.collision.Vector2D d)
- Parameters:
thisD
- Displacement of this tree.t
- A tree of blocks.d
- Displacement of tree t.
- Returns:
- True iff this tree and tree t overlap (account for
displacements).
toString
public String toString()
- Overrides:
toString
in class Object
toString
public String toString(cs2110.collision.Vector2D d)
- Parameters:
d
- Displacement vector.
- Returns:
- String representation of this tree (displaced by d).