Package eas.math.geometry

Examples of eas.math.geometry.Polygon2D


    /* (non-Javadoc)
     * @see eas.simulation.spatial.sim2D.AbstractAgent2D#getShape()
     */
    @Override
    public Polygon2D getAgentShape() {
        Polygon2D p = new Polygon2D(super.getAgentShape());
        p.scale(Vector2D.NULL_VECTOR, new Vector2D(0.5, 0.5));
        return super.getAgentShape();
    }
View Full Code Here


    @Override
    public synchronized boolean setAgentAngle(int agentID, double angleNew) {
        Vector2D posOld = this.getAgentPosition(agentID);
        double angleOld = this.getAgentAngle(agentID);
        Polygon2D shapeOld = this.getAgentShape(agentID);
       
        // Delete old position.
        this.drawTile(
                shapeOld,
                posOld,
                angleOld,
                false);
       
        // Try new position.
        Polygon2D shapeNew = new Polygon2D();
        for (Vector2D v : shapeOld) {
            shapeNew.add(new Vector2D(v));
        }
        shapeNew.rotate(Vector2D.NULL_VECTOR, angleNew);
        for (Vector2D p : shapeNew) {
            if (this.getPix((int) Math.round(p.x + posOld.x), (int) Math.round(p.y + posOld.y))) {
                // Redraw old position.
                this.drawTile(
                        shapeOld,
View Full Code Here

    public Polygon2D getAgentShape() {
//        System.out.println(env.getBombs());
        if (pacman == null || env.getBombs() != bombs || env.isBombRunning()) {
            this.bombs = env.getBombs();
            final float radius = (float) (Math.sqrt(this.bombs) / 2);
            pacman = new Polygon2D();
           
            final float precision = 20;
            final float beg = (float) (-1 * Math.PI / 8);
           
            for (float d = beg; d < Math.PI * 2.1 + beg; d += Math.PI * 2 / precision) {
View Full Code Here

        double transY12 = 3.5;
       
        if (!GlobalVariables.getPrematureParameters().getParValueBoolean("strangeView?")
                && !GlobalVariables.getPrematureParameters().getParValueBoolean("showMinuteSegments")) {
            if (i1 == null) {
                i1 = new Polygon2D();
                i1.add(new Vector2D(-1.5, -10));
                i1.add(new Vector2D(1.5, -10));
                i1.add(new Vector2D(1.5, 6));
                i1.add(new Vector2D(-1.5, 6));
                i1.scale(Vector2D.NULL_VECTOR, new Vector2D(0.1, 0.2));
                i1.translate(new Vector2D(transX12 + 2, -rad + transY12));
            }

            if (i2 == null) {
                i2 = new Polygon2D(i1);
                i2.translate(new Vector2D(1, 0));
            }
           
            if (i3 == null) {
                i3 = new Polygon2D(i2);
                i3.translate(new Vector2D(rad - 5, 19));
            }
           
            if (i4 == null) {
                i4 = new Polygon2D(i3);
                i4.translate(new Vector2D(1, 0));
            }
           
            if (i5 == null) {
                i5 = new Polygon2D(i3);
                i5.translate(new Vector2D(2, 0));
            }

            if (x1 == null) {
                x1 = new Polygon2D();
                x1.add(new Vector2D(-2, -2));
                x1.add(new Vector2D(-10, -10));
                x1.add(new Vector2D(-7, -10));
                x1.add(new Vector2D(0, -3));
                x1.add(new Vector2D(7, -10));
                x1.add(new Vector2D(10, -10));
                x1.add(new Vector2D(2, -2));
                x1.add(new Vector2D(10, 6));
                x1.add(new Vector2D(7, 6));
                x1.add(new Vector2D(0, -1));
                x1.add(new Vector2D(-7, 6));
                x1.add(new Vector2D(-10, 6));
                x1.scale(Vector2D.NULL_VECTOR, new Vector2D(0.1, 0.2));
                x1.translate(new Vector2D(transX12, -rad + transY12));
            }
           
            if (i6 == null) {
                i6 = new Polygon2D(i5);
                i6.translate(new Vector2D(-19.5, 19));
            }
           
            if (v == null) {
                v = new Polygon2D();
                v.add(new Vector2D(-1.5, 6));
                v.add(new Vector2D(1.5, 6));
                v.add(new Vector2D(12.5, -10));
                v.add(new Vector2D(9.5, -10));
                v.add(new Vector2D(0, 4.5));
                v.add(new Vector2D(-0, 4.5));
                v.add(new Vector2D(-9.5, -10));
                v.add(new Vector2D(-12.5, -10));
                v.scale(Vector2D.NULL_VECTOR, new Vector2D(0.1, 0.2));
                v.translate(new Vector2D(-1, 19.5));
            }
           
            if (x2 == null) {
                x2 = new Polygon2D(x1);
                x2.translate(new Vector2D(-17, 19));
            }

            if (i7 == null) {
                i7 = new Polygon2D(i6);
                i6.translate(new Vector2D(-21.5, -19));
            }
           
            Polygon2D x1v = this.getPolygonInVisualization(x1);
            Polygon2D i1v = this.getPolygonInVisualization(i1);
            Polygon2D i2v = this.getPolygonInVisualization(i2);

            Polygon2D i3v = this.getPolygonInVisualization(i3);
            Polygon2D i4v = this.getPolygonInVisualization(i4);
            Polygon2D i5v = this.getPolygonInVisualization(i5);
           
            Polygon2D i6v = this.getPolygonInVisualization(i6);
            Polygon2D vv = this.getPolygonInVisualization(v);
           
            Polygon2D x2v = this.getPolygonInVisualization(x2);
            Polygon2D i7v = this.getPolygonInVisualization(i7);
           
            g.setColor(Color.GRAY);

            g.fillPolygon(x1v.toPol());
            g.fillPolygon(i1v.toPol());
            g.fillPolygon(i2v.toPol());
           
            g.fillPolygon(i3v.toPol());
            g.fillPolygon(i4v.toPol());
            g.fillPolygon(i5v.toPol());
           
            g.fillPolygon(i6v.toPol());
            g.fillPolygon(vv.toPol());
           
            g.fillPolygon(x2v.toPol());
            g.fillPolygon(i7v.toPol());
        }
       
        g.drawImage(img2, 0, 0, null);
       
        return img;
View Full Code Here

    public Polygon2D getAgentShape() {
        if (pol == null) {
            double y = 0.5;
            double x = 2.5;
           
            pol = new Polygon2D();
            pol.add(new Vector2D(-x, -y));
            pol.add(new Vector2D(x, -y));
            pol.add(new Vector2D(x, y));
            pol.add(new Vector2D(-x, y));
        }
View Full Code Here

        super(id, env, params);
    }
   
    @Override
    public Polygon2D getAgentShape() {
        Polygon2D pol = new Polygon2D();
        Vector2D vec1 = new Vector2D(-1, 1);
        Vector2D vec2 = new Vector2D(0, 1);
        Vector2D vec3 = new Vector2D(0, 0);
        Vector2D vec4 = new Vector2D(1, 0);
        pol.add(vec1);
        pol.add(vec2);
        pol.add(vec3);
        pol.add(vec4);
        return pol;
    }
View Full Code Here

        super(id, env, params);
    }
   
    @Override
    public Polygon2D getAgentShape() {
        Polygon2D pol = new Polygon2D();
        Vector2D vec1 = new Vector2D(-1, -1);
        Vector2D vec2 = new Vector2D(-1, 0);
        Vector2D vec3 = new Vector2D(0, 0);
        Vector2D vec4 = new Vector2D(1, 0);
        pol.add(vec1);
        pol.add(vec2);
        pol.add(vec3);
        pol.add(vec4);
        return pol;
    }
View Full Code Here

        super(id, env, params);
    }
   
    @Override
    public Polygon2D getAgentShape() {
        Polygon2D pol = new Polygon2D();
        Vector2D vec1 = new Vector2D(0, 0);
        Vector2D vec2 = new Vector2D(0, 1);
        Vector2D vec3 = new Vector2D(1, 1);
        Vector2D vec4 = new Vector2D(1, 0);
        pol.add(vec1);
        pol.add(vec2);
        pol.add(vec3);
        pol.add(vec4);
        return pol;
    }
View Full Code Here

                    Polygon2D pol;
         
          @Override
          public synchronized Polygon2D getAgentShape() {
                if (pol == null) {
                    pol = new Polygon2D();
                    pol.add(new Vector2D(-1, -1));
                    pol.add(new Vector2D(1, -1));
                    pol.add(new Vector2D(1, 1));
                    pol.add(new Vector2D(-1, 1));
                }
View Full Code Here

        super(id, env, params);
    }
   
    @Override
    public Polygon2D getAgentShape() {
        Polygon2D pol = new Polygon2D();
        Vector2D vec1 = new Vector2D(-1, 1);
        Vector2D vec2 = new Vector2D(-1, 0);
        Vector2D vec3 = new Vector2D(0, 0);
        Vector2D vec4 = new Vector2D(1, 0);
        pol.add(vec1);
        pol.add(vec2);
        pol.add(vec3);
        pol.add(vec4);
        return pol;
    }
View Full Code Here

TOP

Related Classes of eas.math.geometry.Polygon2D

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.