de.steeringbehaviors.simulation.simulationobjects
Class TileNeighborhood

java.lang.Object
  extended by de.steeringbehaviors.simulation.simulationobjects.Simulation
      extended by de.steeringbehaviors.simulation.simulationobjects.Neighborhood
          extended by de.steeringbehaviors.simulation.simulationobjects.TileNeighborhood

public class TileNeighborhood
extends Neighborhood

The Neighborhood class implements a spatial scene lookup table. Normally used as a pre-simulation simulator, it calculates the distances between the vehicles in the scene. It can be used to querry for all vehicles or obstacles within a defined radius of another vehicle.


Nested Class Summary
 class TileNeighborhood.TileInformation
          The TileInformation class holds special informations for each tile.
 
Field Summary
 java.util.Vector m_tiles
          An array of tiles.
 double m_tilesizeX
          The size of a tile along the x axis
 double m_tilesizeY
          The size of a tile along the y axis
 int m_tilesX
          Number of tiles along the x axis
 int m_tilesY
          Number of tiles along the y axis
 
Fields inherited from class de.steeringbehaviors.simulation.simulationobjects.Neighborhood
m_distMatrix, m_nearObstacles, m_nearVehicles, m_nElements
 
Fields inherited from class de.steeringbehaviors.simulation.simulationobjects.Simulation
m_background, m_Obstacle, m_parent, m_postSimulation, m_preSimulation, m_Scene, m_sceneHeight, m_sceneWidth, m_simulationTime, m_useSceneConstraints, m_Vehicles, m_wrapAround
 
Constructor Summary
TileNeighborhood()
          Constructor
 
Method Summary
 void addObstacle(Obstacle newObstacle)
          Adds a new obstacle to the scene description.
 void addVehicle(Vehicle newVehicle)
          Adds a new vehicle to the scene description.
 int getCount()
          Returns the number of elements in the distance matrix
 java.util.Iterator getNearObstacles(Vehicle v, double distance)
          Returns an array of vehicles whose distance from the vehicle is less than the specified distance
 java.util.Iterator getNearVehicles(Vehicle v, double distance)
          Returns an array of vehicles where the distance from the vehicle is less than the specified distance
 java.util.Vector getVehicleList()
          Gives access to the underlying array of vehicles
 void init()
          Initializes the tile matrix.
 void runSimulation()
          Updates the current neighborhood state and recalculates the tile informations.
protected  void scanConvertObstacle(java.util.Vector points, Obstacle newObstacle)
          Sets the accessible flag for all tiles that the obstacle covers.
 void setVehicleList(java.util.Vector vehicleList)
          Replaces the list of vehicles with a new list
 
Methods inherited from class de.steeringbehaviors.simulation.simulationobjects.Neighborhood
removeAll
 
Methods inherited from class de.steeringbehaviors.simulation.simulationobjects.Simulation
addBackground, addGeometrie, addPostSimulation, addPreSimulation, getObstacle, getParent, getScene, getSimulationTime, getVehicles, removeGeometrie, removeObstacle, removeVehicle, setParent, setSceneHeight, setSceneWidth, setUseSceneConstraints, setWrapAround
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_tiles

public java.util.Vector m_tiles
An array of tiles. Each tile holds information about accessibility, vehicles and obstacles


m_tilesizeX

public double m_tilesizeX
The size of a tile along the x axis


m_tilesizeY

public double m_tilesizeY
The size of a tile along the y axis


m_tilesX

public int m_tilesX
Number of tiles along the x axis


m_tilesY

public int m_tilesY
Number of tiles along the y axis

Constructor Detail

TileNeighborhood

public TileNeighborhood()
Constructor

Method Detail

addObstacle

public void addObstacle(Obstacle newObstacle)
Adds a new obstacle to the scene description. The obstacle is automatically added to all pre- and post-Simulations as well.

Overrides:
addObstacle in class Simulation
Parameters:
newObstacle - The obstacle object to add to the scene

addVehicle

public void addVehicle(Vehicle newVehicle)
Adds a new vehicle to the scene description. The vehicle is automatically added to all pre- and post-Simulations as well.

Overrides:
addVehicle in class Neighborhood
Parameters:
newVehicle - The vehicle object to add to the scene

init

public void init()
Initializes the tile matrix. In the initial state, all tiles are considered accessible and do not have any vehicles or obstacles associated with it.

Overrides:
init in class Neighborhood

setVehicleList

public void setVehicleList(java.util.Vector vehicleList)
Replaces the list of vehicles with a new list

Overrides:
setVehicleList in class Neighborhood
Parameters:
vehicleList - Array of vehicles

runSimulation

public void runSimulation()
Updates the current neighborhood state and recalculates the tile informations. No pre- or post-simulation steps are run on this simulator!

Overrides:
runSimulation in class Neighborhood

getCount

public int getCount()
Returns the number of elements in the distance matrix

Overrides:
getCount in class Neighborhood
Returns:
Number of elements in the distance matrix

getNearObstacles

public java.util.Iterator getNearObstacles(Vehicle v,
                                           double distance)
Returns an array of vehicles whose distance from the vehicle is less than the specified distance

Overrides:
getNearObstacles in class Neighborhood
Parameters:
v - Vehicle used as center for search
distance - maximum distance from vehicle
Returns:
Array of obstacles

getNearVehicles

public java.util.Iterator getNearVehicles(Vehicle v,
                                          double distance)
Returns an array of vehicles where the distance from the vehicle is less than the specified distance

Overrides:
getNearVehicles in class Neighborhood
Parameters:
v - Vehicle used as center for search
distance - Maximum distance from vehicle
Returns:
Array of vehicles

getVehicleList

public java.util.Vector getVehicleList()
Gives access to the underlying array of vehicles

Overrides:
getVehicleList in class Neighborhood
Returns:
The array of vehicles

scanConvertObstacle

protected void scanConvertObstacle(java.util.Vector points,
                                   Obstacle newObstacle)
Sets the accessible flag for all tiles that the obstacle covers. The tiles are chosen by scan converting the polygon into tile space.

Parameters:
points - Array of points in world space