org.openmali.spatial.quadtree
Class QuadTree<T extends SpatialNode>

java.lang.Object
  extended by org.openmali.spatial.quadtree.QuadTree<T>

public class QuadTree<T extends SpatialNode>
extends java.lang.Object

This is a non-standard QuadTree implementation. It provides the possibility to use extended cells. These extended cells are cells, that don't cover a quadant of the parent cell, but also a half (one of four).


Field Summary
static PlaneIndicator DEFAULT_PLANE
           
 
Constructor Summary
QuadTree(float centerX, float centerY, float centerZ, AxisIndicator upAxis, float size, float height, boolean useExtendedCells)
           
QuadTree(float centerX, float centerY, float centerZ, AxisIndicator upAxis, float width, float depth, float height, boolean useExtendedCells)
           
QuadTree(float centerX, float centerY, float centerZ, float size, float height, boolean useExtendedCells)
           
QuadTree(float centerX, float centerY, float centerZ, float width, float depth, float height, boolean useExtendedCells)
           
QuadTree(float centerX, float centerY, float centerZ, PlaneIndicator plane, float size, float height, boolean useExtendedCells)
           
QuadTree(float centerX, float centerY, float centerZ, PlaneIndicator plane, float width, float depth, float height, boolean useExtendedCells)
           
QuadTree(Tuple3f center, AxisIndicator upAxis, float size, float height, boolean useExtendedCells)
           
QuadTree(Tuple3f center, AxisIndicator upAxis, float width, float depth, float height, boolean useExtendedCells)
           
QuadTree(Tuple3f center, float size, float height, boolean useExtendedCells)
           
QuadTree(Tuple3f center, float width, float depth, float height, boolean useExtendedCells)
           
QuadTree(Tuple3f center, PlaneIndicator plane, float size, float height, boolean useExtendedCells)
           
QuadTree(Tuple3f center, PlaneIndicator plane, float width, float depth, float height, boolean useExtendedCells)
           
 
Method Summary
 void clear()
          Removes all nodes from this QuadTree.
 void dump()
          Dumps the whole QuadTree to System.out.
 float getCenterX()
           
 float getCenterY()
           
 float getCenterZ()
           
 float getDepth()
           
 int getMaxLevel()
           
 int getMaxLevelForExtendedCells()
           
 int getMinNodesBeforeSplit()
           
 PlaneIndicator getPlane()
           
 QuadCell<T> getRootCell()
           
 AxisIndicator getUpAxis()
           
 float getWidth()
           
 int insertNode(T node)
          Inserts a node into the QuadTree.
 void removeNode(T node)
          Removes the node from the QuadTree (from its container cell).
 void setMaxLevelForExtendedCells(int maxLevelForExtendedCells)
          Sets the maximum number of nodes, that can be inserted into a cell before it is splitted into extended cells.
 void setMinNodesBeforeSplit(int minNodesBeforeSplit)
          Sets the minimum number of nodes, that must be inserted into a cell to make the cell be splitted.
 void updateNodePosition(T node)
          This method must be called after a node's position or size has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PLANE

public static final PlaneIndicator DEFAULT_PLANE
Constructor Detail

QuadTree

public QuadTree(float centerX,
                float centerY,
                float centerZ,
                PlaneIndicator plane,
                float width,
                float depth,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(Tuple3f center,
                PlaneIndicator plane,
                float width,
                float depth,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(float centerX,
                float centerY,
                float centerZ,
                PlaneIndicator plane,
                float size,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(Tuple3f center,
                PlaneIndicator plane,
                float size,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(float centerX,
                float centerY,
                float centerZ,
                AxisIndicator upAxis,
                float width,
                float depth,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(Tuple3f center,
                AxisIndicator upAxis,
                float width,
                float depth,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(float centerX,
                float centerY,
                float centerZ,
                AxisIndicator upAxis,
                float size,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(Tuple3f center,
                AxisIndicator upAxis,
                float size,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(float centerX,
                float centerY,
                float centerZ,
                float width,
                float depth,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(Tuple3f center,
                float width,
                float depth,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(float centerX,
                float centerY,
                float centerZ,
                float size,
                float height,
                boolean useExtendedCells)

QuadTree

public QuadTree(Tuple3f center,
                float size,
                float height,
                boolean useExtendedCells)
Method Detail

getPlane

public final PlaneIndicator getPlane()
Returns:
the plane covered by this QuadTree.

getUpAxis

public final AxisIndicator getUpAxis()
Returns:
the axis used as up-axis by this QuadTree.

getRootCell

public final QuadCell<T> getRootCell()
Returns:
the QuadTree's root QuadCell.

getMaxLevel

public final int getMaxLevel()
Returns:
the maximum currently used level of cells in this QuadTree.

getCenterX

public final float getCenterX()
Returns:
the x-center of this QuadTree (or of the root cell).

getCenterY

public final float getCenterY()
Returns:
the y-center of this QuadTree (or of the root cell).

getCenterZ

public final float getCenterZ()
Returns:
the z-center of this QuadTree (or of the root cell).

getWidth

public final float getWidth()
Returns:
the width of this QuadTree (or of the root cell).

getDepth

public final float getDepth()
Returns:
the depth of this QuadTree (or of the root cell).

setMinNodesBeforeSplit

public void setMinNodesBeforeSplit(int minNodesBeforeSplit)
Sets the minimum number of nodes, that must be inserted into a cell to make the cell be splitted.

Parameters:
minNodesBeforeSplit -

getMinNodesBeforeSplit

public final int getMinNodesBeforeSplit()
Returns:
the minimum number of nodes, that must be inserted into a cell to make the cell be splitted.

setMaxLevelForExtendedCells

public void setMaxLevelForExtendedCells(int maxLevelForExtendedCells)
Sets the maximum number of nodes, that can be inserted into a cell before it is splitted into extended cells.

Parameters:
maxLevelForExtendedCells -

getMaxLevelForExtendedCells

public final int getMaxLevelForExtendedCells()
Returns:
the maximum number of nodes, that can be inserted into a cell before it is splitted into extended cells.

insertNode

public final int insertNode(T node)
Inserts a node into the QuadTree. This first searches the QuadCell to insert and then places the node into the cell.

Parameters:
node -
Returns:
the level of the QuadCell, the node has been inserted to.

removeNode

public final void removeNode(T node)
Removes the node from the QuadTree (from its container cell).

Parameters:
node -

clear

public final void clear()
Removes all nodes from this QuadTree.


updateNodePosition

public final void updateNodePosition(T node)
This method must be called after a node's position or size has changed. You don't need to call this method, if you exactly know, that the modification won't affect the node's placement in the tree.

Parameters:
node -

dump

public void dump()
Dumps the whole QuadTree to System.out.