Package eas.math.geometry

Examples of eas.math.geometry.Rectangle2D


    }

    @Override
    public Vector2D getRealPosFromScreenPos(Vector2D screenPos) {
        Vector2D pos = new Vector2D(screenPos.x, screenPos.y);
        Rectangle2D box = env.getCurrentViewBox();
       
        Polygon2D pinkBorder = env.getPinkBorder();
       
        pos.sub(new Vector2D(
                pinkBorder.getBoundingBox().upperLeftCorner().x,
                pinkBorder.getBoundingBox().upperLeftCorner().y));
       
        pos.x = pos.x / env.globalScale();
        pos.y = pos.y / env.globalScale();
       
        pos.translate(box.upperLeftCorner());
       
        if (env.getVisualizationAngleCenterPoint() != null) {
            pos.rotate(env.getVisualizationAngleCenterPoint(), -env.getVisualizationAngleRAD());
        }
       
View Full Code Here


        Vector2D liob = new Vector2D(((AbstractEnvironment2D) this.getEnvironment()).getAgentPosition(this.id()));
        Vector2D reun = new Vector2D(liob);
        liob.sub(new Vector2D(this.kantenLaenge, this.kantenLaenge));
        reun.translate(new Vector2D(this.kantenLaenge, this.kantenLaenge));
       
        Rectangle2D box = new Rectangle2D(liob, reun);
        @SuppressWarnings({ "rawtypes", "unchecked" })
        List<Integer> idList = ((AbstractEnvironment2D) this.getEnvironment()).calculateAgentsInBox(box);
        List<Evolvable<AbstractEvolvableAgent2D<AbstractEnvironment2D<?>>>> jasmineList = new ArrayList<Evolvable<AbstractEvolvableAgent2D<AbstractEnvironment2D<?>>>>(idList.size());
       
        for (int i : idList) {
View Full Code Here

  }

    @Override
    public Polygon2D getAgentShape() {
        if (wandaShape == null) {
            wandaShape = new Rectangle2D(new Vector2D(-0.5*cShapeSize,-0.5*cShapeSize),
                           new Vector2D(0.5*cShapeSize,0.5*cShapeSize)).toPol2D();
            if(this.getBrain() instanceof MDL2eBrain<?> && ((MDL2eBrain<?>) this.getBrain()).isActive())
                wandaShape.add(2, new Vector2D(0, 0.75*cShapeSize));
           
            /*wandaShape.add(Vector2D.NULL_VECTOR);
 
View Full Code Here

        Scene2D<AgentType> scaledScene = new Scene2D<AgentType>("", this.pars);
        Scene2D<AgentType> sceneCopy = new Scene2D<AgentType>("", this.pars);
        scaledScene.addScene(this);
        sceneCopy.addScene(this);
       
        Rectangle2D boundingBox = this.getBoundingBox();
        double currentWidth = boundingBox.getWidth();
        double currentHeight = boundingBox.getHeight();
        double desiredWidth = Math.abs(lowerRight.x - upperLeft.x);
        double desiredHeight = Math.abs(lowerRight.y - upperLeft.y);
        Vector2D newUpperLeftCorner = new Vector2D(Math.min(upperLeft.x, lowerRight.x), Math.min(upperLeft.y, lowerRight.y));
        Vector2D newLowerRightCorner = new Vector2D(Math.max(upperLeft.x, lowerRight.x), Math.max(upperLeft.y, lowerRight.y));
       
View Full Code Here

        super("Rectangular Obstacle Scene", params);
        Scene2D<AbstractAgent2D<?>> scene;
        Scene2D<AbstractAgent2D<?>> sceneComplete = new Scene2D<AbstractAgent2D<?>>("Complete scene", params);
        int numberOfGridsPerDir = numberOfRowsAndColumns;
        Random rand = new Random(params.getSeed());
        Rectangle2D boundThis;
        double factor;
       
        for (int i = 0; i < numberOfGridsPerDir; i++) {
            for (int j = 0; j < numberOfGridsPerDir; j++) {
                scene = new ObstacleScene(params);
                scene.removeAgent(rand.nextInt(4));
                scene.addCollidingAgent(
                        new JebensAgent(0, null, params),
                        scene.getBoundingBox().middle(),
                        0,
                        new Vector2D(1, 1));
                scene.translateScene(new Vector2D(750 * i, 750 * j));
                sceneComplete.addScene(scene);
            }
        }
        boundThis = sceneComplete.getBoundingBox();
        Vector2D middleOfThis;
        if (boundThis != null) {
            middleOfThis = boundThis.middle();
        } else {
            middleOfThis = new Vector2D(0, 0);
        }
        middleOfThis.mult(-1);
        sceneComplete.translateScene(middleOfThis);
View Full Code Here

            String title = id;
            if (!windowsLoaded.contains(title)) {
                return;
            }
           
            Rectangle2D rect = new Rectangle2D(
                    window.getX(),
                    window.getY(),
                    window.getX() + window.getWidth(),
                    window.getY() + window.getHeight());
            windowRectangles.put(title, rect);
View Full Code Here

            LinkedList<String> lines = liesTextArray(new File("./sharedDirectory/simFrames.dat"), GlobalVariables.getPrematureParameters());
           
            for (String s : lines) {
                String[] ss = s.split(" === ");
                String title = ss[0];
                Rectangle2D rect = Rectangle2D.parseRectangle2D(ss[1]);
               
                if (title.equals(id)) {
                    for (int i = 0; i < 10; i++) {
                        window.setLocation(
                                (int) rect.upperLeftCorner().x,
                                (int) rect.upperLeftCorner().y);
                        window.setSize(
                                (int) rect.lowerRightCorner().x - (int) rect.upperLeftCorner().x,
                                (int) rect.lowerRightCorner().y - (int) rect.upperLeftCorner().y);
                    }
                }
               
                windowRectangles.put(title, rect);
            }
View Full Code Here

            final Random rand) {
        super("Rectangular Obstacle Scene", params);
        Scene2D<AbstractAgent2D<?>> scene;
        Scene2D<AbstractAgent2D<?>> sceneComplete = new Scene2D<AbstractAgent2D<?>>("Complete scene", params);
        int numberOfGridsPerDir = numberOfRowsAndColumns;
        Rectangle2D boundThis;
        double factor;
       
        for (int i = 0; i < numberOfGridsPerDir; i++) {
            for (int j = 0; j < numberOfGridsPerDir; j++) {
                scene = new ObstacleScene(params);
                for (int t = 0; t <= rand.nextInt(2); t++) {
                    scene.removeAgent(rand.nextInt(4));
                }
                scene.translateScene(new Vector2D(750 * i, 750 * j));
                sceneComplete.addScene(scene);
            }
        }
        boundThis = sceneComplete.getBoundingBox();
        Vector2D middleOfThis;
        if (boundThis != null) {
            middleOfThis = boundThis.middle();
        } else {
            middleOfThis = new Vector2D(0, 0);
        }
        middleOfThis.mult(-1);
        sceneComplete.translateScene(middleOfThis);
View Full Code Here

        super(environment);
    }

    @Override
    public Vector2D getPointInVisualization(Vector3D fieldPos2) {
        Rectangle2D bdb = this.env.getBoundingBox(false);
        Vector2D envSizeTrans = new Vector2D(bdb.middle());
        envSizeTrans.div(-1);
       
        Vector2D fieldPos = new Vector2D(fieldPos2.x, fieldPos2.y);
        fieldPos.translate(envSizeTrans);
       
View Full Code Here

    @Override
    public Vector2D getRealPosFromScreenPos(Vector2D screenPos) {
        Vector2D pos = super.getRealPosFromScreenPos(screenPos);

        Rectangle2D bdb = this.env.getBoundingBox(false);
        Vector2D envSizeTrans = new Vector2D(bdb.middle());
       
        /*
         * The "position inside a polygon" information might be calculated
         * slightly incorrect due to distortion of polygons. (TODO: fix that
         * in environment.)
View Full Code Here

TOP

Related Classes of eas.math.geometry.Rectangle2D

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.