Package eas.math.geometry

Examples of eas.math.geometry.Polygon2D


    public DynamiteAgent(int id,
            AbstractEnvironment2D<?> env,
            ParCollection params) {
        super(id, env, params, new Color(0, 0, 0, 0));
        shape = new Polygon2D();
        shape.add(new Vector2D(-0.5f, -0.5f));
        shape.add(new Vector2D(0.5f, -0.5f));
        shape.add(new Vector2D(0.5f, 0.5f));
        shape.add(new Vector2D(-0.5f, 0.5f));
    }
View Full Code Here


    @Override
    public Polygon2D getAgentShape() {
        if (pacman == null) {
            final float precision = 15;
            final float radius = (float) 0.5;
            pacman = new Polygon2D();
           
            final float beg = (float) (-1 * Math.PI / 8);
           
            for (float d = beg; d < Math.PI * 2.1 + beg; d += Math.PI * 2 / precision) {
                pacman.add(new Vector2D((float) (Math.sin(d) * radius), (float) (Math.cos(d) * radius)));
 
View Full Code Here

    private Polygon2D shape;
   
    @Override
    public synchronized Polygon2D getAgentShape() {
        if (shape == null) {
            shape = new Polygon2D();
//            shape.add(new Vector2D(0, 1));
            shape.add(new Vector2D(-0.35, -1));
            shape.add(new Vector2D(-0.35, 1));
            shape.add(new Vector2D(0.35, 1));
            shape.add(new Vector2D(0.35, -1));
View Full Code Here

    private static final long serialVersionUID = 1777008593393055203L;
    private Polygon2D shape;
   
    public SmallAgent(int id, ClockEnvironment env, ParCollection params) {
        super(id, env, params);
        shape = new Polygon2D(new SecondAgent(0, null, params).getAgentShape());
        shape.scale(new Vector2D(0, 0), new Vector2D(0.35, 0.083));
    }
View Full Code Here

    private Polygon2D shape;
   
    @Override
    public synchronized Polygon2D getAgentShape() {
        if (shape == null) {
            shape = new Polygon2D();
//            shape.add(new Vector2D(0, 1));
            shape.add(new Vector2D(0.3, -1));
            shape.add(new Vector2D(2, 11));
            shape.add(new Vector2D(0, 18));
            shape.add(new Vector2D(-2, 11));
View Full Code Here

    public FuseAgent(int id,
            AbstractEnvironment2D<?> env,
            ParCollection params) {
        super(id, env, params, new Color(0, 0, 0, 0));
        shape = new Polygon2D();
        shape.add(new Vector2D(-0.5f, -0.5f));
        shape.add(new Vector2D(0.5f, -0.5f));
        shape.add(new Vector2D(0.5f, 0.5f));
        shape.add(new Vector2D(-0.5f, 0.5f));
    }
View Full Code Here

   
    @Override
    public Polygon2D getAgentShape() {
        if (pol == null) {
            Polygon p;
            Polygon2D p2;
            ParCollection params = this.getPars();
           
            p = new ArrowMaster(params).pfeilEinfach(5, 5, -5, -5, 0.25, false);
            p2 = new Polygon2D();
            for (int i = 0; i < p.npoints; i++) {
                p2.add(new Vector2D(p.xpoints[i], p.ypoints[i]));
            }
           
            pol = p2;
        }
       
View Full Code Here

    protected synchronized void drawTile(
            Polygon2D tile,
            Vector2D pos,
            double angle,
            boolean color) {
        Polygon2D tileTurned = new Polygon2D();
        for (Vector2D v : tile) {
            tileTurned.add(new Vector2D(v));
        }
        tileTurned.rotate(Vector2D.NULL_VECTOR, angle);
       
        for (Vector2D p : tileTurned) {
            Vector2D gesPos = new Vector2D(pos);
            gesPos.translate(p);
            this.setPix((int) Math.round(gesPos.x), (int) Math.round(gesPos.y), color);
View Full Code Here

        }
    }
   
    @Override
    public synchronized boolean setAgentPosition(int agentID, Vector2D newPosition) {
        Polygon2D tile = this.getAgent(agentID).getAgentShape();
        // Delete old position.
        this.drawTile(
                this.getAgent(agentID).getAgentShape(),
                this.getAgentPosition(agentID),
                this.getAgentAngle(agentID),
                false);
       
        // Try new position.
        Polygon2D newShape = new Polygon2D();
        for (Vector2D v : tile) {
            newShape.add(new Vector2D(v));
        }
        newShape.rotate(Vector2D.NULL_VECTOR, this.getAgentAngle(agentID));
        for (Vector2D p : newShape) {
            Vector2D reqPos = new Vector2D(newPosition);
            reqPos.translate(p);
            if (this.getPix((int) Math.round(reqPos.x), (int) Math.round(reqPos.y))) {
                // Redraw old position.
View Full Code Here

//            stroke2 = new CompositeStroke(new BasicStroke(5f), new BasicStroke(0.5f));
//        }
       
        Vector2D aktPos = this.getAgentPosition(0);
        Vector2D newpos = new Vector2D(aktPos);
        Polygon2D pol = this.getAgentShape(0);
        double angle = this.getAgentAngle(0);
       
        newpos.translate(new Vector2D(0, 1));
        if (!this.setAgentPosition(0, newpos)) {
            this.removeAgent(0);
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.