Package eas.math.geometry

Examples of eas.math.geometry.Vector2D


   */
  @SuppressWarnings("rawtypes")
  public Entry<Integer, Color> getSensedColor() {
   
    AbstractEnvironment2D env = body.getEnvironment();
    Vector2D bodyPos = env.getAgentPosition(body.id());
   
    //add all AbstractAgent2D except body to check list
    List<Integer> agentsToCheck = new ArrayList<Integer>();
    for (Object o : env.getAgents()) {
      if (o instanceof AbstractAgent2D && env.isCollidingAgent(((AbstractAgent2D<?>) o).id())
          && !((AbstractAgent2D<?>) o).equals(body)) {
        AbstractAgent2D<?> agent = (AbstractAgent2D<?>) o;
        agentsToCheck.add(agent.id());
      }
    }
   
    //construct sensor LOV
    Vector2D sensorLOV = env.getNormalizedLOV(body.id());
    sensorLOV.rotate(Vector2D.NULL_VECTOR, angleToAgent);
    sensorLOV.setLength(cSensorReach);
   
    LineSegment2D sensorLine = new LineSegment2D(
        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();) {
View Full Code Here


                    ignoreList.add(agt);
                }
            }
        }
       
        Vector2D lov = new Vector2D(env.getNormalizedLOV(agent.id()));

        lov.rotate(Vector2D.NULL_VECTOR, 5 * Math.PI / 3);

        CollisionData collData;
       
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
View Full Code Here

    public int fitness(final RobEA rob) {

        // Wall-Follow:
        final double epsilon = 0.1;
        int wf = 0;
        Vector2D blick = new Vector2D(rob.getBlickrichtung());
        blick.norm();
//        if (Math.abs(blick.y) < epsilon) {
        if (Math.abs(blick.x) < epsilon || Math.abs(blick.y) < epsilon) {
            wf++;
        } else {
            wf--;
View Full Code Here

                    ignoreList.add(agt);
                }
            }
        }
       
        Vector2D lov = new Vector2D(env.getNormalizedLOV(agent.id()));

        lov.rotate(Vector2D.NULL_VECTOR, Math.PI);

        CollisionData collData;
       
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
View Full Code Here

   
    TreeMap<Double, AbstractAgent2D<?>> agentsInSensorField = new TreeMap<Double, AbstractAgent2D<?>>();
    Random rand = new Random();
   
    AbstractEnvironment2D<?> env = body.getEnvironment();
    Vector2D bodyPos = new Vector2D(env.getAgentPosition(body.id()));
   
    //add all AbstractAgent2D except body to check list
    List<Integer> agentsToCheck = new ArrayList<Integer>();
    for (Object o : env.getAgents()) {
      if (o instanceof AbstractAgent2D && !((AbstractAgent2D<?>) o).equals(body)) {
        AbstractAgent2D<?> agent = (AbstractAgent2D<?>) o;
        agentsToCheck.add(agent.id());
      }
    }
   
    for(double d = cSensorPrecision; d <= cSensorReach; d += cSensorPrecision){
     
      Vector2D sensorLOV = env.getNormalizedLOV(body.id());
      sensorLOV.rotate(Vector2D.NULL_VECTOR, angleToAgent);
      sensorLOV.setLength(d);
     
      //construct point on sonar line with a distance of D to body
      Vector2D sonarPoint = new Vector2D(sensorLOV).translate(bodyPos);
     
      //a = (x, y) -> b = (-x, y) ==> perpendicular vector
      Vector2D sonarLOV = new Vector2D(-sensorLOV.x, sensorLOV.y);
      double sonarLength = Math.tan(cSensorWidth/2) * d;
      // construct direction vector pointing to sonar line end points perpendicular to sensorLOV and of appropriate length
      sonarLOV.setLength(sonarLength);
     
      LineSegment2D sonarLine = new LineSegment2D(
          new Vector2D(sonarPoint).translate(sonarLOV),
          new Vector2D(sonarPoint).sub(sonarLOV));
     
      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(sonarLine);
View Full Code Here

      if (msg != null) {
        // Nachricht vorhanden, berechne Signalqualitaet und Richtung.
        msg.setDistance(agent.getKey());
       
        //angle seen from self = Angle between own LOV and vector to sender
        Vector2D  vecToSender = new Vector2D(env.getAgentPosition(wanda.id()));
        vecToSender.sub(env.getAgentPosition(body.id()));
       
        Vector2D ownLOV = env.getNormalizedLOV(body.id());
        int dir = ownLOV.drehrichtung(vecToSender) ? -1 : 1;
       
        msg.setAngleSeenFromSelf(dir * Math.toDegrees(ownLOV.angle(vecToSender)));       
       
        //angle seen from remote = Angle between sender LOV and vector to self
        vecToSender.mult(-1);
        Vector2D senderLOV = env.getNormalizedLOV(wanda.id());
        dir = senderLOV.drehrichtung(vecToSender) ? -1 : 1;
       
        msg.setAngleSeenFromRemote(dir * Math.toDegrees(senderLOV.angle(vecToSender)));
       
        //orientation of sender = Angle between sender LOV and own LOV
                dir = ownLOV.drehrichtung(senderLOV) ? -1 : 1;
               
                msg.setSenderOrientation(dir * Math.toDegrees(ownLOV.angle(senderLOV)));
 
View Full Code Here

        int faktor = (int) aktivSeitLetzt / 10;

        rob.resetAktivZyk(rob.getAktAutNum());
       
        if (rob.getLetztKoord() == null) {
            rob.setLetztKoord(new Vector2D(rob.getPosition()));
        }
       
        if (this.haelfte(rob.getEnvironmentEA(), rob.getLetztKoord())
            != this.haelfte(rob.getEnvironmentEA(), rob.getPosition())) {
            fitSwap = 10;
            GlobaleMARBVariablen.setGateCount(GlobaleMARBVariablen.getGateCount() + 1);
        } else {
            fitSwap = -1;
        }
       
        rob.setLetztKoord(new Vector2D(rob.getPosition()));
       
        return fitSwap * faktor;
    }
View Full Code Here

                    ignoreList.add(agt);
                }
            }
        }
       
        Vector2D lov = new Vector2D(env.getNormalizedLOV(agent.id()));

        lov.rotate(Vector2D.NULL_VECTOR, 4 * Math.PI / 3);

        CollisionData collData;
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, ignoreList);
View Full Code Here

        if (this.letztePos == null) {
            this.letztePos = new Vector2D[rob.getEnvironment().getAgents().size()];
            return 0;
        }
        if (this.letztePos[rob.id()] == null) {
            this.letztePos[rob.id()] = new Vector2D(rob.getPosition());
            return 0;
        }
       
        entfernung = this.letztePos[rob.id()].distance(rob.getPosition())
                    * rob.getPars().getParValueDouble(eas.statistics.ConstantsStatistics.VERZERR_ATTR);
       
        this.letztePos[rob.id()] = new Vector2D(rob.getPosition());
       
        return (int) entfernung;
    }
View Full Code Here

    public int fitness(final RobEA rob) {
        // Swap:
        int fitSwap;
       
        if (rob.getLetztKoord() == null) {
            rob.setLetztKoord(new Vector2D(rob.getPosition()));
        }
       
        if (this.haelfte(rob.getEnvironmentEA(), rob.getLetztKoord())
            != this.haelfte(rob.getEnvironmentEA(), rob.getPosition())) {
            fitSwap = 1;
            GlobaleMARBVariablen.setGateCount(GlobaleMARBVariablen.getGateCount() + 1);
        } else {
            fitSwap = 0;
        }

        rob.setLetztKoord(new Vector2D(rob.getPosition()));
       
        return fitSwap;
    }
View Full Code Here

TOP

Related Classes of eas.math.geometry.Vector2D

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.