cs2110.collision
Class BlockTree

java.lang.Object
  extended by cs2110.collision.BlockTree

public class BlockTree
extends java.lang.Object

An instance is a non-empty collection of points organized in a hierarchical binary tree structure.


Constructor Summary
BlockTree(java.util.ArrayList<Block> blocks)
          Constructor: a binary tree containing blocks.
 
Method Summary
 boolean contains(Vector2D p)
          Return true iff this collection of blocks contains point p.
 BoundingBox getBox()
          Return the bounding box of the collection of blocks.
 int getNumBlocks()
          Return the number of blocks contained in this tree.
 boolean isIntermediate()
          Return true iff this is an intermediate node.
 boolean isLeaf()
          Return true iff this is a leaf node.
 boolean overlaps(Vector2D thisD, BlockTree t, Vector2D d)
          Return true iff (this tree displaced by thisD) and (tree t displaced by d) overlap.
 java.lang.String toString()
          Return a representation of this instance.
 java.lang.String toString(Vector2D d)
          Return a represenation of d
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BlockTree

public BlockTree(java.util.ArrayList<Block> blocks)
Constructor: a binary tree containing blocks. Precondition: The tree has no be non-empty, i.e. it must contain at least one block.

Method Detail

getBox

public BoundingBox getBox()
Return the bounding box of the collection of blocks.

Returns:
The bounding box of this collection of blocks.

isLeaf

public boolean isLeaf()
Return true iff this is a leaf node.

Returns:
true iff this is a leaf node.

isIntermediate

public boolean isIntermediate()
Return true iff this is an intermediate node.

Returns:
true iff this is an intermediate node.

getNumBlocks

public int getNumBlocks()
Return the number of blocks contained in this tree.

Returns:
Number of blocks contained in this tree.

contains

public boolean contains(Vector2D p)
Return true iff this collection of blocks contains point p.

Returns:
True iff this collection of blocks contains point p.

overlaps

public boolean overlaps(Vector2D thisD,
                        BlockTree t,
                        Vector2D d)
Return true iff (this tree displaced by thisD) and (tree t displaced by d) overlap.

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 java.lang.String toString()
Return a representation of this instance.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(Vector2D d)
Return a represenation of d

Parameters:
d - Displacement vector.
Returns:
String representation of this tree (displaced by d).