Package eas.simulation.spatial.sim2D.standardEnvironments

Examples of eas.simulation.spatial.sim2D.standardEnvironments.CollisionData


      public Integer sense(AbstractEnvironment2D<AbstractAgent2D<?>> env, AbstractAgent2D<?> agent) {
        int result = -1;
        Vector2D angle= new Vector2D(env.getNormalizedLOV(agent.id()).x,env.getNormalizedLOV(agent.id()).y);
        angle.rotate(Vector2D.NULL_VECTOR, -45+0*(90/(3-1.0))*Math.PI/180);

        CollisionData coll = env.nearestRayCollision(
            env.getAgentPosition(agent.id()),
            angle,
            agent);

        if ((coll.getCollisionPoint()!=null&&coll.getCollisionPoint().distance(env.getAgentPosition(agent.id()))<15)){
          result = coll.getAgent().id();
        }

        return result;
      }
    });

    this.addSensor(new GenericSensor<Integer, AbstractEnvironment2D<AbstractAgent2D<?>>, AbstractAgent2D<?>>() {

      /**
             *
             */
            private static final long serialVersionUID = 187236060508880836L;

            @Override
      public String id() {
        return "sensing-agent-1";
      }

      @Override
      public Integer sense(AbstractEnvironment2D<AbstractAgent2D<?>> env, AbstractAgent2D<?> agent) {
        int result = -1;
        Vector2D angle= new Vector2D(env.getNormalizedLOV(agent.id()).x,env.getNormalizedLOV(agent.id()).y);
        angle.rotate(Vector2D.NULL_VECTOR, -45+1*(90/(3-1.0))*Math.PI/180);

        CollisionData coll = env.nearestRayCollision(
            env.getAgentPosition(agent.id()),
            angle,
            agent);

        if ((coll.getCollisionPoint()!=null&&coll.getCollisionPoint().distance(env.getAgentPosition(agent.id()))<15)){
          result = coll.getAgent().id();
        }

        return result;
      }
    });

    this.addSensor(new GenericSensor<Integer, AbstractEnvironment2D<AbstractAgent2D<?>>, AbstractAgent2D<?>>() {

      /**
             *
             */
            private static final long serialVersionUID = -2034243692637537731L;

            @Override
      public String id() {
        return "sensing-agent-2";
      }

      @Override
      public Integer sense(AbstractEnvironment2D<AbstractAgent2D<?>> env, AbstractAgent2D<?> agent) {
        int result = -1;
        Vector2D angle= new Vector2D(env.getNormalizedLOV(agent.id()).x,env.getNormalizedLOV(agent.id()).y);
        angle.rotate(Vector2D.NULL_VECTOR, -45+2*(90/(3-1.0))*Math.PI/180);

        CollisionData coll = env.nearestRayCollision(
            env.getAgentPosition(agent.id()),
            angle,
            agent);

        if ((coll.getCollisionPoint()!=null&&coll.getCollisionPoint().distance(env.getAgentPosition(agent.id()))<15)){
          result = coll.getAgent().id();
        }

        return result;
      }
    });
View Full Code Here


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

//        agent.v = new Vector2D(env.getAgentPosition(agent.id()));
//        lov.laengeFestlegen(100);
//        agent.v.add(lov);
        CollisionData collData;
       
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, ignoreList);
        } else {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, agent);
        }       
       
       
        double distance;
        try {
            distance = collData.getCollisionPoint().distance(
                    env.getAgentPosition(agent.id()));
        } catch (Exception e) {
            distance = Double.POSITIVE_INFINITY;
        }

        if (JasmineRobot.isJasmineRobot(collData.getAgent())) {
            distance *= ConstantsSimulation.ROBOTER_KONST;
        }

        return (int) Math.round(JasmineRobot.konst2 * Math.pow(JasmineRobot.konst1, distance));
    }
View Full Code Here

       
        Vector2D lov = new Vector2D(env.getNormalizedLOV(agent.id()));

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

        CollisionData collData;
       
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, ignoreList);
        } else {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, agent);
        }

        double distance;
        try {
            distance = collData.getCollisionPoint().distance(
                    env.getAgentPosition(agent.id()));
        } catch (Exception e) {
            distance = Double.POSITIVE_INFINITY;
        }

        if (JasmineRobot.isJasmineRobot(collData.getAgent())) {
            distance *= ConstantsSimulation.ROBOTER_KONST;
        }

        return (int) Math.round(JasmineRobot.konst2 * Math.pow(JasmineRobot.konst1, distance));
    }
View Full Code Here

       
        Vector2D lov = new Vector2D(env.getNormalizedLOV(agent.id()));

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

        CollisionData collData;
       
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, ignoreList);
        } else {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, agent);
        }
       
        double distance;
        try {
            distance = collData.getCollisionPoint().distance(
                    env.getAgentPosition(agent.id()));
        } catch (Exception e) {
            distance = Double.POSITIVE_INFINITY;
        }

        if (JasmineRobot.isJasmineRobot(collData.getAgent())) {
            distance *= ConstantsSimulation.ROBOTER_KONST;
        }

        return (int) Math.round(JasmineRobot.konst2 * Math.pow(JasmineRobot.konst1, distance));
    }
View Full Code Here

       
        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);
        } else {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, agent);
        }       
       
        double distance;
        try {
            distance = collData.getCollisionPoint().distance(
                    env.getAgentPosition(agent.id()));
        } catch (Exception e) {
            distance = Double.POSITIVE_INFINITY;
        }

        if (JasmineRobot.isJasmineRobot(collData.getAgent())) {
            distance *= ConstantsSimulation.ROBOTER_KONST;
        }

        return (int) Math.round(JasmineRobot.konst2 * Math.pow(JasmineRobot.konst1, distance));
    }
View Full Code Here

                    ignoreList.add(agt);
                }
            }
        }
       
        CollisionData collData;
       
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()),
                    env.getNormalizedLOV(agent.id()), ignoreList);
        } else {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()),
                    env.getNormalizedLOV(agent.id()), agent);
        }
       
        double distance;
        try {
            distance = collData.getCollisionPoint().distance(
                    env.getAgentPosition(agent.id()));
        } catch (Exception e) {
            distance = Double.POSITIVE_INFINITY;
        }

        if (JasmineRobot.isJasmineRobot(collData.getAgent())) {
            distance *= ConstantsSimulation.ROBOTER_KONST;
        }

        return (int) Math.round(JasmineRobot.konst2 * Math.pow(JasmineRobot.konst1, distance));
    }
View Full Code Here

                    ignoreList.add(agt);
                }
            }
        }
       
        CollisionData collData;
       
        if (isLight) {
             collData = env.nearestRayCollision(
                    env.getAgentPosition(agent.id()),
                    env.getNormalizedLOV(agent.id()),
                    ignoreList);
        } else {
            collData = env.nearestRayCollision(
                    env.getAgentPosition(agent.id()),
                    env.getNormalizedLOV(agent.id()),
                    agent);
        }
       
       
        double distance;
        try {
            distance = collData.getCollisionPoint().distance(
                    env.getAgentPosition(agent.id()));
        } catch (Exception e) {
            distance = Double.POSITIVE_INFINITY;
        }

        distance *= ConstantsSimulation.BEAMER_KONST;

        if (JasmineRobot.isJasmineRobot(collData.getAgent())) {
            distance *= ConstantsSimulation.ROBOTER_KONST;
        }

        return (int) Math.round(JasmineRobot.konst2
                * Math.pow(JasmineRobot.konst1, distance));
View Full Code Here

       
        Vector2D lov = new Vector2D(env.getNormalizedLOV(agent.id()));

        lov.rotate(Vector2D.NULL_VECTOR, 2 * Math.PI / 3);
       
        CollisionData collData;
       
        if (isLight) {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, ignoreList);
        } else {
            collData = env.nearestRayCollisionIgnoreNonColliding(
                    env.getAgentPosition(agent.id()), lov, agent);
        }

        double distance;
        try {
            distance = collData.getCollisionPoint().distance(
                    env.getAgentPosition(agent.id()));
        } catch (Exception e) {
            distance = Double.POSITIVE_INFINITY;
        }

        if (JasmineRobot.isJasmineRobot(collData.getAgent())) {
            distance *= ConstantsSimulation.ROBOTER_KONST;
        }

        return (int) Math.round(JasmineRobot.konst2 * Math.pow(JasmineRobot.konst1, distance));
    }
View Full Code Here

                            PacmanGhostAgent.ignorelist.add((AbstractAgent2D<?>) a);
                        }
                    }
                }
               
                CollisionData collision0 = env.nearestRayCollision(
                        pos,
                        env.getNormalizedLOV(PacmanGhostAgent.this.id()),
                        PacmanGhostAgent.ignorelist);

                zwisch = new Vector2D(pos);
                zwisch.norm();
                zwisch.setLength(3);

                pos.sub(zwisch);

                CollisionData collision1 = env.nearestRayCollision(pos,
                        env.getNormalizedLOV(PacmanGhostAgent.this.id()),
                        PacmanGhostAgent.ignorelist);

                pos.translate(zwisch);
                pos.translate(zwisch);

                CollisionData collision2 = env.nearestRayCollision(pos,
                        env.getNormalizedLOV(PacmanGhostAgent.this.id()),
                        PacmanGhostAgent.ignorelist);

                return collision0.getAgent() != null
                    || collision1.getAgent() != null
                    || collision2.getAgent() != null;
            }

            @Override
            public String id() {
                return "Pacman sensor";
View Full Code Here

TOP

Related Classes of eas.simulation.spatial.sim2D.standardEnvironments.CollisionData

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.