de.steeringbehaviors.simulation.behaviors
Class Containment

java.lang.Object
  extended by de.steeringbehaviors.simulation.behaviors.Behavior
      extended by de.steeringbehaviors.simulation.behaviors.Containment
All Implemented Interfaces:
ObjectAttributes

public class Containment
extends Behavior

ObstacleAvoidance Implements the Containment behavior. This behavior is used to steer an object around obstacles in its way by using three testpoints.


Field Summary
protected  double m_frontAngle
          The angle to the obstacle in front of the vehicle
protected  double m_frontDistance
          The distance to the obstacle in front of the vehicle
protected  boolean m_frontIntersection
          Predicates, whether the front test vector intersects an obsacle or not
protected  Point2d m_frontIntersectionPoint1
          The first point of an intersected line-segment in front of the vehicle
protected  Point2d m_frontIntersectionPoint2
          The second point of an intersected line-segment in front of the vehicle
protected  Vector2d m_frontTest
          Vector used for testing the front for possible collisions
protected  java.lang.Double[] m_info
          Used as return value
protected  double m_leftAngle
          The angle to the obstacle on the left side of the vehicle
protected  double m_leftDistance
          The distance to the obstacle on the left side of the vehicle
protected  boolean m_leftIntersection
          Predicates, whether the left test vector intersects an obsacle or not
protected  Point2d m_leftIntersectionPoint1
          The first point of an intersected line-segment on the left side of the vehicle
protected  Point2d m_leftIntersectionPoint2
          The second point of an intersected line-segment on the left side of the vehicle
protected  Vector2d m_leftTest
          Vector used for testing the left side for possible collisions
protected  Neighborhood m_neighborhood
          A neighborhood object used for spatial queries
protected  double m_rightAngle
          The angle to the obstacle on the right side of the vehicle
protected  double m_rightDistance
          The distance to the obstacle on the right side of the vehicle
protected  boolean m_rightIntersection
          Predicates, whether the right test vector intersects an obsacle or not
protected  Point2d m_rightIntersectionPoint1
          The first point of an intersected line-segment on the right side of the vehicle
protected  Point2d m_rightIntersectionPoint2
          The second point of an intersected line-segment on the right side of the vehicle
protected  Vector2d m_rightTest
          Vector used for testing the right side for possible collisions
 
Fields inherited from class de.steeringbehaviors.simulation.behaviors.Behavior
m_behaviorName, m_influence, m_needsNeighborhood
 
Constructor Summary
Containment()
          Constructor
 
Method Summary
 Vector2d calculate(Vehicle v)
          Calculates the resulting force vector for this frame
protected  java.lang.Double[] getCollisionDetails(Vehicle v, Obstacle o, Vector2d testvector, Point2d retPoint1, Point2d retPoint2)
          Returns the angle and the distance to the collided object.
 void init()
          Inits the object
 void setAttribute(java.lang.String name, java.lang.String value, java.util.Hashtable objectList)
          Sets a attribute specified by the name
 boolean setSpecialObject(java.lang.String objectDesc, java.lang.Object specialObject)
          Use this function if you need to pass a special object to certain behaviors, but do not know which behavior really recognizes this object.
 
Methods inherited from class de.steeringbehaviors.simulation.behaviors.Behavior
getBehaviorName, getInfluence, needsNeighborhood, setInfluence, setNeighborhood
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_frontTest

protected Vector2d m_frontTest
Vector used for testing the front for possible collisions


m_leftTest

protected Vector2d m_leftTest
Vector used for testing the left side for possible collisions


m_rightTest

protected Vector2d m_rightTest
Vector used for testing the right side for possible collisions


m_neighborhood

protected Neighborhood m_neighborhood
A neighborhood object used for spatial queries


m_frontIntersection

protected boolean m_frontIntersection
Predicates, whether the front test vector intersects an obsacle or not


m_leftIntersection

protected boolean m_leftIntersection
Predicates, whether the left test vector intersects an obsacle or not


m_rightIntersection

protected boolean m_rightIntersection
Predicates, whether the right test vector intersects an obsacle or not


m_info

protected java.lang.Double[] m_info
Used as return value


m_frontDistance

protected double m_frontDistance
The distance to the obstacle in front of the vehicle


m_frontAngle

protected double m_frontAngle
The angle to the obstacle in front of the vehicle


m_frontIntersectionPoint1

protected Point2d m_frontIntersectionPoint1
The first point of an intersected line-segment in front of the vehicle


m_frontIntersectionPoint2

protected Point2d m_frontIntersectionPoint2
The second point of an intersected line-segment in front of the vehicle


m_leftDistance

protected double m_leftDistance
The distance to the obstacle on the left side of the vehicle


m_leftAngle

protected double m_leftAngle
The angle to the obstacle on the left side of the vehicle


m_leftIntersectionPoint1

protected Point2d m_leftIntersectionPoint1
The first point of an intersected line-segment on the left side of the vehicle


m_leftIntersectionPoint2

protected Point2d m_leftIntersectionPoint2
The second point of an intersected line-segment on the left side of the vehicle


m_rightDistance

protected double m_rightDistance
The distance to the obstacle on the right side of the vehicle


m_rightAngle

protected double m_rightAngle
The angle to the obstacle on the right side of the vehicle


m_rightIntersectionPoint1

protected Point2d m_rightIntersectionPoint1
The first point of an intersected line-segment on the right side of the vehicle


m_rightIntersectionPoint2

protected Point2d m_rightIntersectionPoint2
The second point of an intersected line-segment on the right side of the vehicle

Constructor Detail

Containment

public Containment()
Constructor

Method Detail

init

public void init()
Inits the object


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.String value,
                         java.util.Hashtable objectList)
Sets a attribute specified by the name

Specified by:
setAttribute in interface ObjectAttributes
Overrides:
setAttribute in class Behavior
Parameters:
name - name of the attribute
value - value of the attribute
objectList - hashtable of all steeringobjects

setSpecialObject

public boolean setSpecialObject(java.lang.String objectDesc,
                                java.lang.Object specialObject)
Use this function if you need to pass a special object to certain behaviors, but do not know which behavior really recognizes this object. If a behavior recognized the objectDesc, it will return true and cast the object to the correct type internally. If the behavior does not know the objectDesc, it will return false.

Overrides:
setSpecialObject in class Behavior
Parameters:
objectDesc - A string that represents a certain object type
specialObject - An instance of a special object that corresponds to the objectDesc
Returns:
True if the behvaior recognized the description, otherwise False

getCollisionDetails

protected java.lang.Double[] getCollisionDetails(Vehicle v,
                                                 Obstacle o,
                                                 Vector2d testvector,
                                                 Point2d retPoint1,
                                                 Point2d retPoint2)
Returns the angle and the distance to the collided object. Returns null, if no collision is detected. The first element of the double[] array is the distance, the second one is the angle

Parameters:
v - The vehicle
o - The obstacle
testvector - Testvector for collision detection
Returns:
A double array. The first element represents the distance to the object, the second one the angle. Null is returned, if no collision is detected

calculate

public Vector2d calculate(Vehicle v)
Calculates the resulting force vector for this frame

Overrides:
calculate in class Behavior
Parameters:
v - The vehicle
Returns:
Returns the resulting force