org.graphstream.boids
Class BoidForces

java.lang.Object
  extended by org.graphstream.boids.BoidForces
Direct Known Subclasses:
GreedyForces, NTreeForces

public abstract class BoidForces
extends Object

Models the forces applied to a boid at each step.

This object is modified at each computation step to represent the forces applied to a boid particle in the forces system. It is in charge of going down the n-tree used to represent space and collect all the other boids in the field of view that could influence this boid. It then integrates these forces and compute a direction and barycenter (the point the boid tries to reach).

Author:
Guilhelm Savin, Antoine Dutot

Field Summary
 org.miv.pherd.geom.Vector3 attraction
          The integrated attraction toward other boids in view at each step.
 org.miv.pherd.geom.Point3 barycenter
          The position the boid tries to reach at each step.
 int countAtt
          The number of boids we are attracted to.
 int countRep
          The number of boids we are repulsed from.
 org.miv.pherd.geom.Vector3 direction
          The direction of the boid at each step.
 org.miv.pherd.geom.Vector3 repulsion
          The integrated repulsion from the other boids in view at each step.
 
Constructor Summary
BoidForces(Boid b)
          Forces all set at zero.
 
Method Summary
 void addAttraction(org.miv.pherd.geom.Vector3 att)
          Integrate an attraction vector.
 void addDirection(org.miv.pherd.geom.Vector3 dir)
          Integrate a direction influence.
 void addRepulsion(org.miv.pherd.geom.Vector3 rep)
          Integrate a repulsion vector.
 void compute()
          Compute the forces applied to a boid under the form of a barycenter that the boids tries to reach (attraction), an overall direction for all the surrounding boids, an overall direction of all the surrounding boids.
 org.miv.pherd.geom.Vector3 getDirection()
           
abstract  Collection<Boid> getNeighborhood()
           
abstract  org.miv.pherd.geom.Point3 getNextPosition()
           
abstract  org.miv.pherd.geom.Point3 getPosition()
           
 boolean isVisible(Boid boid, org.miv.pherd.geom.Point3 point)
          True if the given position is visible by the boid.
 void moveBarycenter(org.miv.pherd.geom.Point3 p)
          Integrate a new point of influence.
abstract  void setPosition(double x, double y, double z)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

barycenter

public org.miv.pherd.geom.Point3 barycenter
The position the boid tries to reach at each step.


direction

public org.miv.pherd.geom.Vector3 direction
The direction of the boid at each step.


attraction

public org.miv.pherd.geom.Vector3 attraction
The integrated attraction toward other boids in view at each step.


repulsion

public org.miv.pherd.geom.Vector3 repulsion
The integrated repulsion from the other boids in view at each step.


countAtt

public int countAtt
The number of boids we are attracted to.


countRep

public int countRep
The number of boids we are repulsed from.

Constructor Detail

BoidForces

public BoidForces(Boid b)
Forces all set at zero.

Method Detail

compute

public void compute()
Compute the forces applied to a boid under the form of a barycenter that the boids tries to reach (attraction), an overall direction for all the surrounding boids, an overall direction of all the surrounding boids.


addRepulsion

public void addRepulsion(org.miv.pherd.geom.Vector3 rep)
Integrate a repulsion vector.


addDirection

public void addDirection(org.miv.pherd.geom.Vector3 dir)
Integrate a direction influence.


addAttraction

public void addAttraction(org.miv.pherd.geom.Vector3 att)
Integrate an attraction vector.


moveBarycenter

public void moveBarycenter(org.miv.pherd.geom.Point3 p)
Integrate a new point of influence.


isVisible

public boolean isVisible(Boid boid,
                         org.miv.pherd.geom.Point3 point)
True if the given position is visible by the boid.

This method first check if the given point is under the max distance of view. If so, it checks if the point is in the angle of view. The angle of view is specified as the cosine of the angle between the boid direction vector and the vector between the boid and the given point. This means that -1 is equal to a 360 degree of vision (the angle of view test is deactivated in this case), 0 means 180 degree angle, and 0.5 a 90 degree angle for example.

Parameters:
boid - The source boid.
point - The point to consider.
Returns:
True if point is visible by source.

getDirection

public org.miv.pherd.geom.Vector3 getDirection()

setPosition

public abstract void setPosition(double x,
                                 double y,
                                 double z)

getPosition

public abstract org.miv.pherd.geom.Point3 getPosition()

getNextPosition

public abstract org.miv.pherd.geom.Point3 getNextPosition()

getNeighborhood

public abstract Collection<Boid> getNeighborhood()


Copyright © 2013. All Rights Reserved.