de.steeringbehaviors.simulation.simulationobjects
Class Neighborhood

java.lang.Object
  extended by de.steeringbehaviors.simulation.simulationobjects.Simulation
      extended by de.steeringbehaviors.simulation.simulationobjects.Neighborhood
Direct Known Subclasses:
TileNeighborhood

public class Neighborhood
extends Simulation

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.


Field Summary
protected  double[][] m_distMatrix
          Distance matrix
protected  java.util.Vector m_nearObstacles
           
protected  java.util.Vector m_nearVehicles
           
protected  int m_nElements
          Number of elements in the distance matrix
 
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
Neighborhood()
          Constructor
 
Method Summary
 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 whose 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 neighborhood object distance matrix
 void removeAll()
          Removes all objects from the scene description.
 void runSimulation()
          Updates the current neighborhood state and recalculates the distance informations.
 void setVehicleList(java.util.Vector vehicleList)
          Replaces the list of vehicles with a new list
 
Methods inherited from class de.steeringbehaviors.simulation.simulationobjects.Simulation
addBackground, addGeometrie, addObstacle, 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_distMatrix

protected double[][] m_distMatrix
Distance matrix


m_nearObstacles

protected java.util.Vector m_nearObstacles

m_nearVehicles

protected java.util.Vector m_nearVehicles

m_nElements

protected int m_nElements
Number of elements in the distance matrix

Constructor Detail

Neighborhood

public Neighborhood()
Constructor

Method Detail

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 Simulation
Parameters:
newVehicle - The vehicle object to add to the scene

init

public void init()
Initializes the neighborhood object distance matrix


removeAll

public void removeAll()
Removes all objects from the scene description. The pre- and post-simulations are also cleared of all objects

Overrides:
removeAll in class Simulation

setVehicleList

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

Parameters:
vehicleList - Array of vehicles

runSimulation

public void runSimulation()
Updates the current neighborhood state and recalculates the distance informations. If the number of vehicles has changed, the distance matrix is completely regenerated. No pre- or post-simualtion steps are run on this simulator!

Overrides:
runSimulation in class Simulation

getCount

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

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

Parameters:
v - Vehicle used as center for search
distance - maximum distance from vehicle
Returns:
Array of vehicles

getNearVehicles

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

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

Returns:
The array of vehicles