Package eas.math.geometry

Examples of eas.math.geometry.Vector2D


    /**
     * Berechnet die Eckpunkte des Roboters.
     */
    private void berechneEckpunkte() {
        Vector2D e1 = new Vector2D(this.position.x, this.position.y);
        Vector2D e2 = new Vector2D(this.position.x, this.position.y);
        Vector2D e3 = new Vector2D(this.position.x, this.position.y);
        Vector2D e4 = new Vector2D(this.position.x, this.position.y);
        Vector2D b = this.blickrichtung;
        Vector2D bn = new Vector2D(-this.blickrichtung.y, this.blickrichtung.x);

        e1.x = e1.x + (b.x * this.ausd.x + bn.x * this.ausd.y) / 2;
        e1.y = e1.y + (b.y * this.ausd.x + bn.y * this.ausd.y) / 2;
        e2.x = e2.x + (b.x * this.ausd.x - bn.x * this.ausd.y) / 2;
        e2.y = e2.y + (b.y * this.ausd.x - bn.y * this.ausd.y) / 2;
View Full Code Here


     */
    @Override
    public Polygon2D getAgentShape() {
        if (pol == null) {
            pol = new Polygon2D();
            pol.add(new Vector2D(-this.ausd.x / 2, -this.ausd.y / 2));
            pol.add(new Vector2D(+this.ausd.x / 2, -this.ausd.y / 2));
            pol.add(new Vector2D(+this.ausd.x / 2, +this.ausd.y / 2));
            pol.add(new Vector2D(-this.ausd.x / 2, +this.ausd.y / 2));
        }
       
        return pol;
    }
View Full Code Here

              * this.pars.getParValueDouble(eas.statistics.ConstantsStatistics.VERZERR_ATTR);
       
        double b = this.ausd.x * this.pars.getParValueDouble(eas.statistics.ConstantsStatistics.VERZERR_ATTR);
        double rad;
        double alpha;
        Vector2D neuPos = new Vector2D(this.getPosition());
        Vector2D mitte = new Vector2D(this.getPosition());
        Vector2D richtung = new Vector2D(this.getBlickrichtung());
        Vector2D altePos;
        double alteBlick;
        boolean bool;

        if (Math.abs(l) < this.epsilon && Math.abs(r) < this.epsilon) {
            return true; // Beide Räder auf Null.
        } else if (Math.abs(l - r) < this.epsilon) { // Differenz gleich.
            neuPos = new Vector2D(this.getPosition());
            richtung = new Vector2D(this.getBlickrichtung());
            richtung.setLength(r);
            neuPos.translate(richtung);
            // umg.setzeLinie(mitte.x, mitte.y, neuPos.x, neuPos.y,
            // Konstanten.FARBEN_BENUTZER[farbe], true, false, true, false);
            return this.setPos(neuPos.x, neuPos.y, false);
        } else if (Math.abs(l + r) < this.epsilon) { // Genau entgegengesetzt.
            rad = b / 2;
            alpha = r / rad;
            // umg.setzeLinie(mitte.x, mitte.y, neuPos.x, neuPos.y,
            // Konstanten.FARBEN_BENUTZER[farbe], true, false, true, false);
            return this.setAngle(this.getAngle() - alpha / Math.PI * 180);
        } else if (Math.abs(l) > Math.abs(r)) {
            rad = b / (l / r - 1) + b / 2;
            richtung.ortho();
            richtung.setLength(rad);
            mitte.sub(richtung);
            if (r * l > 0) { // r und l haben dasselbe Vorzeichen.
                alpha = r / rad;
            } else {
                alpha = 2 * r / b;
            }
            alpha = l / rad;
            neuPos.rotate(mitte, alpha);
            altePos = new Vector2D(this.getPosition());
            alteBlick = this.getAngle();
            bool = this.setPos(neuPos.x, neuPos.y, false);
            // umg.setzeLinie(mitte.x, mitte.y, neuPos.x, neuPos.y,
            // Konstanten.FARBEN_BENUTZER[farbe], true, false, true, false);
            if (bool) {
                bool = this.setAngle(this.getAngle() + alpha / Math.PI * 180);
                if (!bool) {
                    this.setAngle(alteBlick);
                    this.setPos(altePos.x, altePos.y, false);
                    return false;
                }
                return true;
            } else {
                this.setPos(altePos.x, altePos.y, false);
                return false;
            }
        } else if (Math.abs(r) > Math.abs(l)) {
            rad = b / (r / l - 1) + b / 2;
            richtung.ortho();
            richtung.setLength(rad);
            mitte.translate(richtung);
            if (r * l > 0) { // r und l haben dasselbe Vorzeichen.
                alpha = r / rad;
            } else {
                alpha = 2 * r / b;
            }
            neuPos.rotate(mitte, -alpha);
            altePos = new Vector2D(this.getPosition());
            alteBlick = this.getAngle();
            bool = this.setPos(neuPos.x, neuPos.y, false);
            // umg.setzeLinie(mitte.x, mitte.y, neuPos.x, neuPos.y,
            // Konstanten.FARBEN_BENUTZER[farbe], true, false, true, false);
            if (bool) {
View Full Code Here

  @Override
  public Polygon2D getAgentShape() {
    if (shape == null) {
      shape = super.getAgentShape();
      shape.scale(Vector2D.NULL_VECTOR, new Vector2D(7, 7));
    }
    return shape;
  }
View Full Code Here

   
    @Override
    public strictfp Polygon2D getAgentShape() {
        if (shape == null) {
            shape = new Polygon2D();
            shape.add(new Vector2D(0, 0));
            shape.add(new Vector2D(25, 0));
            shape.add(new Vector2D(25, 2));
            shape.add(new Vector2D(0, 2));
        }
       
        return shape;
    }
View Full Code Here

        if (e.getEventDescription().equals(" ")) {
            this.panic = true;
            PanicGhostAgent g = new PanicGhostAgent(99999, this, 1000, pars);
            this.addAgent(
                    g,
                    new Vector2D(PanicAgent.fireLocation.x, PanicAgent.fireLocation.y),
                    0);
        } else if (e.getEventDescription().equals("r")) {
            this.panic = false;
//            this.removeAgent(99999);
            this.reset(55);
View Full Code Here

    public double getOutsideForce(int agentID) {
        AgentList<PhysicsAgent2D<?>> agentlist = this.getAgent(agentID).getTouching();
        double fges = 0;

        for (int i = 0; i < agentlist.size(); i++) {
            Vector2D pos = new Vector2D(agentlist.get(i).getPosition().getX(),
                    agentlist.get(i).getPosition().getY());
            if (pos.distance(this.getAgentPosition(agentID)) <= PanicAgent.radius * 2) {
                fges += agentlist.get(i).getForce().length();
            }
        }

        return fges;
View Full Code Here

        }
       
        for (int i = 1000; i < 1000 + agents; i++) {
            this.addAgent(
                    new PanicAgent(i, this, 30, pars),
                    new Vector2D(
                            rand.nextDouble() * 90 + 5,
                            rand.nextDouble() * 90 + 5),
                    rand.nextDouble() * 360,
                    new Vector2D(1, 1));
        }
    }
View Full Code Here

    }

    @Override
    public Polygon2D getAgentShape() {
        Polygon2D p = new Polygon2D();
        p.add(new Vector2D(-250, -width));
        p.add(new Vector2D(250, -width));
        p.add(new Vector2D(250, width));
        p.add(new Vector2D(-250, width));
        return p;
    }
View Full Code Here

        this.gravity = gravity;
        this.iterations = iterations;
    }

    public Vector2D vecPhysToVec2D(final ROVector2f vec) {
        return new Vector2D(vec.getX(), vec.getY());
    }
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.