Package eas.simulation.spatial.sim2D.standardAgents

Examples of eas.simulation.spatial.sim2D.standardAgents.AbstractAgent2D


        new Vector2D(bodyPos),
        new Vector2D(bodyPos).translate(sensorLOV));

    //find closest agent
    Double minDistance = Double.POSITIVE_INFINITY;
    AbstractAgent2D closestAgent = null;
    for (Iterator<Integer> iterator = agentsToCheck.iterator(); iterator.hasNext();) {
      Integer agentID = iterator.next();
      //for all remaining agents check for intersection
      List<Vector2D> isPoints = env.getAgentShapeInEnvironment(agentID).intersectAll(sensorLine);
     
      if(!isPoints.isEmpty()){       
        //find intersection point with least distance
        for (Vector2D isPoint : isPoints) {
          isPoint.sub(bodyPos);
          if(Double.compare(isPoint.length(), minDistance) < 0){
             minDistance = isPoint.length();
             closestAgent = env.getAgent(agentID);
          }         
        }
      }

    }

    if(closestAgent != null)
      return new SimpleEntry<Integer, Color>((int) Math.round(minDistance), closestAgent.getAgentColor());
   
    return new SimpleEntry<Integer, Color>((int) Math.round(cSensorReach), Color.BLACK);
  }
View Full Code Here

TOP

Related Classes of eas.simulation.spatial.sim2D.standardAgents.AbstractAgent2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.