Package eas.math.geometry

Examples of eas.math.geometry.Polygon2D


                Color.black, new Color(200, 200, 200), true, true);
        AusgMerkm ausgGELBPassiv = new AusgMerkm(
                Color.black, new Color(200, 200, 200), true, true);
        AusgMerkm ausgROTPassiv = new AusgMerkm(
                Color.black, new Color(200, 200, 200), true, true);
        Polygon2D quad = new Polygon2D();
        Vector2D xSub = new Vector2D(radius * 1.5, 0);
        Vector2D ySub = new Vector2D(0, radius * 1.5);
        Vector2D zwisch;
        zwisch = new Vector2D(linksOben);
        zwisch.sub(xSub);
        zwisch.sub(ySub);
        quad.add(zwisch);

        zwisch = new Vector2D(linksOben.x, linksOben.y + radius * 4 + radius);
        zwisch.sub(xSub);
        zwisch.translate(ySub);
        quad.add(zwisch);

        zwisch = new Vector2D(linksOben.x, linksOben.y + radius * 4 + radius);
        zwisch.translate(xSub);
        zwisch.translate(ySub);
        quad.add(zwisch);

        zwisch = new Vector2D(linksOben.x, linksOben.y);
        zwisch.translate(xSub);
        zwisch.sub(ySub);
        quad.add(zwisch);
       
        AusgMerkm zwAusg = new AusgMerkm(Color.black, Color.black, true, true);
        liste.add(zwAusg);
        liste.add(quad.toPol(1, Vector2D.NULL_VECTOR));
       
        Circle2D k1 = new Circle2D(
                linksOben.x,
                linksOben.y,
                radius);
View Full Code Here


       
        Vector2D anfWin = new Vector2D(this.pfeilPol.get(1));
        anfWin.sub(this.pfeilPol.get(0));
        double winkel = Math.atan(anfWin.x / anfWin.y);
       
        Polygon2D p = (new ArrowMaster(this.pars)).segmentPfeilPol2D(
                this.pfeilPol,
                this.dicken,
                ArrowMaster.EINFACHER_ABSCHLUSS,
                this.anfang,
                new Vector2D(this.anfFakt, this.anfFakt),
                new Vector2D(1, 1));
       
        p.translate(versch);
       
        p.scale(
                Vector2D.NULL_VECTOR,
                new Vector2D(1 / this.dicken.get(0), 1 / this.dicken.get(0)));
       
        p.rotate(Vector2D.NULL_VECTOR, winkel);
       
        return p;
    }
View Full Code Here

                        unmark2,
                        4);
            }
           
            if (this.ersteEcke != null && this.zweiteEcke != null) {
                Polygon2D quad = new Polygon2D();
               
                quad.add(new Vector2D(this.ersteEcke));
                quad.add(new Vector2D(this.ersteEcke.x, this.zweiteEcke.y));
                quad.add(new Vector2D(this.zweiteEcke));
                quad.add(new Vector2D(this.zweiteEcke.x, this.ersteEcke.y));
               
                liste.add(new AusgMerkm(
                        Color.lightGray,
                        Color.black,
                        true,
                        false));
                liste.add(quad.toPol(this.skalierung, this.verschiebung));
            }
           
            LinkedList<AbstractMsg> msgsError
                = this.pars.getMsgs(
                    (new MsgError(null, 0, null)).getType(),
View Full Code Here

     *
     * @param bezKonst  Die Bezierkonstante.
     */
    public void bezier(final double bezKonst) {
        double bezK = bezKonst;
        Polygon2D bez;
        Vector2D v1, v2, v3, v4;
        ArrayList<Integer> mark = new ArrayList<Integer>(4);
       
        if (bezK > 1) {
            bezK = eas.startSetup.marbBuilder.zeichenModi.ConstantsZeichenModi.BEZ_NORMAL;
        }
       
        if (this.mark1 != null
                && this.mark2 != null
                && !this.mark1.equals(this.mark2)
                && this.markierte.size() == 4) {
           
            mark.addAll(this.markierte);
               
            Collections.sort(this.markierte, new IntComp());

            v1 = this.pfeilPol.get(mark.get(0));
            v2 = this.pfeilPol.get(mark.get(1));
            v3 = this.pfeilPol.get(mark.get(2));
            v4 = this.pfeilPol.get(mark.get(3));

            bez = Geometry2D.bezierKurve(v1, v2, v3, v4, bezK);
           
            Polygon2D polNeu = new Polygon2D();
            ArrayList<Double> dickenNeu = new ArrayList<Double>();
            boolean platziert = false;
           
            for (int i = 0; i < this.pfeilPol.nPoints(); i++) {
                if (!this.between(mark.get(0), mark.get(3), i)) {
                    polNeu.add(this.pfeilPol.get(i));
                    dickenNeu.add(this.dicken.get(i));
                } else if (!platziert) {
                    for (int n = 0; n < bez.nPoints(); n++) {
                        polNeu.add(bez.get(n));
                        dickenNeu.add(this.dicken.get(i));
                    }
                    platziert = true;
                }
            }
View Full Code Here

                double translation = 0;
                Color color = Color.orange;

                translation += 5;

                Polygon2D points = new Polygon2D();
                ArrayList<Double> thicks = new ArrayList<Double>(2);

                thicks.add(2.5);
                thicks.add(2.5);
                Vector2D startPoint = new Vector2D(10 + translation, i
                        * (nodesize + 10) + 10 + nodesize / 2 - 1);
                points.add(startPoint);
                points.add(new Vector2D(30 + translation, i * (nodesize + 10)
                        + 10 + nodesize / 2 - 1));

                Polygon2D arrow = this.pfeilMaster.segmentPfeilPol2D(points,
                        thicks, ArrowMaster.KUGEL_ENDE,
                        ArrowMaster.EINFACHE_SPITZE_1, new Vector2D(1, 1),
                        new Vector2D(1, 1));
                g.setColor(color);
                g.fillPolygon(arrow.toPol());
                g.setColor(Color.black);
                g.drawPolygon(arrow.toPol());
                g.drawString(StaticMethods.round(currentNeuron.getInput(), 2)
                        + "", (float) startPoint.x, (float) startPoint.y - 5);
            }

            if (currentNeuron.isOutput()) {
                Color color = Color.orange;
                double translation = 0;
                Polygon2D points = new Polygon2D();
                ArrayList<Double> thicks = new ArrayList<Double>(2);
                translation = this.neurons.size() * (nodesize + 10) + 40;
                translation += 5;

                thicks.add(2.5);
                thicks.add(2.5);
                Vector2D startPoint = new Vector2D(10 + translation, i
                        * (nodesize + 10) + 10 + nodesize / 2 - 1);
                points.add(startPoint);
                points.add(new Vector2D(30 + translation, i * (nodesize + 10)
                        + 10 + nodesize / 2 - 1));

                Polygon2D arrow = this.pfeilMaster.segmentPfeilPol2D(points,
                        thicks, ArrowMaster.KUGEL_ENDE,
                        ArrowMaster.EINFACHE_SPITZE_1, new Vector2D(1, 1),
                        new Vector2D(1, 1));
                g.setColor(color);
                g.fillPolygon(arrow.toPol());
                g.setColor(Color.black);
                g.drawPolygon(arrow.toPol());
                g.drawString(StaticMethods.round(currentNeuron.getOutput(), 2)
                        + "", (float) startPoint.x, (float) startPoint.y - 8);

                color = Color.orange;
            }

            // Draw links.
            double maxWeight = Double.NEGATIVE_INFINITY;
            double minWeight = Double.POSITIVE_INFINITY;

            for (NeuralLink link : currentNeuron.getIncomingLinks()) {
                if (link.getWeight() > maxWeight) {
                    maxWeight = link.getWeight();
                }
                if (link.getWeight() < minWeight) {
                    minWeight = link.getWeight();
                }
            }

            for (NeuralLink link : currentNeuron.getIncomingLinks()) {
                Polygon2D points = new Polygon2D();
                ArrayList<Double> thicks = new ArrayList<Double>(2);
                Vector2D weightPos = null;
                double weightFactor;

                if (Math.abs(maxWeight) > Math.abs(minWeight)) {
                    minWeight = -maxWeight;
                } else {
                    maxWeight = -minWeight;
                }

                if (link.getWeight() >= 0) {
                    weightFactor = link.getWeight() / maxWeight;
                } else {
                    weightFactor = link.getWeight() / minWeight;
                }
                if (weightFactor > 0 && weightFactor < 0.26) {
                    weightFactor = 0.26;
                }
                if (weightFactor <= 0 && weightFactor > -0.26) {
                    weightFactor = -0.26;
                }

                if (Double.isNaN(weightFactor)) {
                    weightFactor = 0.1;
                }

                thicks.add(4 * weightFactor);
                thicks.add(4 * weightFactor);
                thicks.add(4 * weightFactor);

                Neuron otherNeuron = this.getNeuron(link.getSourceNeuronID());

                Font font;
                if (Math.abs(weightFactor) > 0.5) {
                    font = new Font("", Font.BOLD, 12);
                } else {
                    font = new Font("", Font.PLAIN, 10);
                }

                if (otherNeuron.getId() < currentNeuron.getId()) {
                    // Regular link from earlier neuron.
                    points.add(new Vector2D(otherNeuron.getId()
                            * (nodesize + 10) + 50 + nodesize / 2, otherNeuron
                            .getId() * (nodesize + 10) + 10 + nodesize));
                    points.add(new Vector2D(otherNeuron.getId()
                            * (nodesize + 10) + 50 + nodesize / 2,
                            currentNeuron.getId() * (nodesize + 10) + 10
                                    + nodesize / 2));
                    points.add(new Vector2D(currentNeuron.getId()
                            * (nodesize + 10) + 40, currentNeuron.getId()
                            * (nodesize + 10) + 10 + nodesize / 2));
                    weightPos = new Vector2D(otherNeuron.getId()
                            * (nodesize + 10) + 53 + nodesize / 2,
                            currentNeuron.getId() * (nodesize + 10) + 10
                                    + nodesize / 2 - 3);
                } else if (otherNeuron.getId() > currentNeuron.getId()) {
                    // Reccurent link from later neuron.
                    points.add(new Vector2D(otherNeuron.getId()
                            * (nodesize + 10) + 50 + nodesize / 2, otherNeuron
                            .getId() * (nodesize + 10) + 10 + nodesize));
                    points.add(new Vector2D(otherNeuron.getId()
                            * (nodesize + 10) + 50 + nodesize / 2,
                            currentNeuron.getId() * (nodesize + 10) + 10
                                    + nodesize / 2));
                    points.add(new Vector2D(currentNeuron.getId()
                            * (nodesize + 10) + 60 + nodesize, currentNeuron
                            .getId() * (nodesize + 10) + 10 + nodesize / 2));
                    weightPos = new Vector2D(otherNeuron.getId()
                            * (nodesize + 10) + 53 + nodesize / 2,
                            currentNeuron.getId() * (nodesize + 10) + 10
                                    + nodesize / 2 - 3);
                } else {
//                     Reccurent link from same neuron.
                    double epsilon = 0.05;
                    double radius = nodesize / 2.0 - 2;
                    double x = currentNeuron.getId() * (nodesize + 10) + 51 + nodesize / 2.0;
                    double y = currentNeuron.getId() * (nodesize + 10) + 11 + nodesize / 2.0;
                    thicks.clear();
                   
                    for (double d = 0; d < Math.PI * 2; d += epsilon) {
                        points.add(new Vector2D(x + Math.cos(d) * radius, y + Math.sin(d) * radius));
                        thicks.add(0 * weightFactor);
                    }
                    
                    weightPos = new Vector2D(otherNeuron.getId()
                            * (nodesize + 10) + 60, currentNeuron.getId()
                            * (nodesize + 10) + 8);
                    weightFactor = Double.POSITIVE_INFINITY;
                }

                double spitzenFactor = 1.0;
                if (weightFactor < 0) {
                    spitzenFactor = -1.0;
                }

                if (points.size() > 0) {
                    Polygon2D arrow = ArrowMaster.DOPPELSPITZES_ENDE;
                    try {
                        arrow = this.pfeilMaster.segmentPfeilPol2D(points,
                                thicks, ArrowMaster.DOPPELSPITZES_ENDE,
                                ArrowMaster.EINFACHE_SPITZE_1, new Vector2D(
                                        spitzenFactor * 1 / weightFactor / 1.7,
                                        1 / weightFactor / 1.7), new Vector2D(
                                        spitzenFactor * 1 / weightFactor / 1.7,
                                        1 / weightFactor / 1.7));
                    } catch (Exception e) {
                        GlobalVariables.getPrematureParameters().logStage1(Arrays.deepToString(e.getStackTrace()));
                    }

                    if (link.getWeight() > 0) {
                        g.setColor(Color.black);
                    } else {
                        g.setColor(Color.red);
                    }
                    g.fillPolygon(arrow.toPol());
                }

                if (link.getWeight() > 0) {
                    g.setColor(Color.black);
                } else {
View Full Code Here

        if (pars.getParValueBoolean("ShowSelectionSquare")) {
            Graphics2D g = img.createGraphics();
            double width = pars
                    .getParValueDouble("SelektionsQuadratKantenlaenge");
            Rectangle2D rect;
            Polygon2D pol;

            g.setColor(Color.LIGHT_GRAY);
            for (AbstractAgent<?> a : this.getAgents()) {
                if (JasmineRobot.isJasmineRobot(a)) {
                    rect = new Rectangle2D(
                            new Vector2D(this.getAgentPosition(a.id()).x
                                    - width / 2,
                                    this.getAgentPosition(a.id()).y - width / 2),
                            new Vector2D(this.getAgentPosition(a.id()).x
                                    + width / 2,
                                    this.getAgentPosition(a.id()).y + width / 2));
                    pol = rect.toPol2D();
                    pol = this.getPolygonInVisualization(pol);
                    g.drawPolygon(pol.toPol());
                }
            }
        }

        return img;
View Full Code Here

public class Arrows {
    public static void main(String[] args) {
        ArrayList<Object> l = new ArrayList<Object>(1);

        ArrayList<Double> dicken2;
        Polygon2D bez2 = new Polygon2D();
       
        double r1 = 190 * 1.9;
        double r2 = 190 * 1.9;
        Vector2D versch = new Vector2D(400, 500);

        bez2.clear();

        bez2.add(new Vector2D(1200, 500 + 190 * 1.9));
       
        for (double i = 0.5 * Math.PI; i < 2 * Math.PI - 0.01; i += 0.001) {
            Vector2D point = new Vector2D(r1 * Math.cos(i), r2 * Math.sin(i));
            point.add(versch);
            bez2.add(point);
            r1 -= 0.004;
            r2 -= 0.004;
        }

        bez2.add(new Vector2D(742, 580));

        bez2 = bez2.normalize(GlobalVariables.getPrematureParameters());
       
        dicken2 = new ArrayList<Double>(bez2.size());
        int p1 = 2000;
        int p2 = 330;
       
        for (double i = 0; i < p1; i++) {
            dicken2.add(50.0);
        }
        for (double i = p1; i < bez2.size() - p2; i++) {
            dicken2.add(((i - p1 + 50) * Math.sqrt(i - p1 + 50)) / 500.0 + 50);
        }
        for (double i = bez2.size() - p2; i < bez2.size(); i++) {
            dicken2.add((bez2.size() - i) / 2 + 125);
        }
       
        AusgMerkm[] strichelung = new AusgMerkm[] {
                new AusgMerkm(Color.black, Color.white, true, false),
                new AusgMerkm(Color.black, Color.white, true, true) };
View Full Code Here

        try {ImageIO.write(img, "png", outputfile);} catch (IOException e) {}
    }

    public static Polygon2D getPolygon() {
        ArrayList<Double> dicken2;
        Polygon2D bez2 = new Polygon2D();
       
        double r1 = 190 * 1.9;
        double r2 = 190 * 1.9;
        Vector2D versch = new Vector2D(400, 500);

        bez2.clear();

        bez2.add(new Vector2D(1200, 500 + 190 * 1.9));
       
        for (double i = 0.5 * Math.PI; i < 2 * Math.PI - 0.01; i += 0.001) {
            Vector2D point = new Vector2D(r1 * Math.cos(i), r2 * Math.sin(i));
            point.add(versch);
            bez2.add(point);
            r1 -= 0.004;
            r2 -= 0.004;
        }

        bez2.add(new Vector2D(742, 580));

        bez2 = bez2.normalize(GlobalVariables.getPrematureParameters());
       
        dicken2 = new ArrayList<Double>(bez2.size());
        int p1 = 2000;
        int p2 = 330;
       
        for (double i = 0; i < p1; i++) {
            dicken2.add(50.0);
        }
        for (double i = p1; i < bez2.size() - p2; i++) {
            dicken2.add(((i - p1 + 50) * Math.sqrt(i - p1 + 50)) / 500.0 + 50);
        }
        for (double i = bez2.size() - p2; i < bez2.size(); i++) {
            dicken2.add((bez2.size() - i) / 2 + 125);
        }

        Polygon2D pol =
                new ArrowMaster(GlobalVariables.getPrematureParameters()).segmentPfeilPol2D(
                        bez2,
                        dicken2,
                        ArrowMaster.EINFACHER_ABSCHLUSS,
                        ArrowMaster.KUGEL_ENDE,
                        new Vector2D(1, 1),
                        new Vector2D(0.45, 0.45));
       
        pol.rotate(pol.centerPoint(), Math.PI);
        pol = pol.normalize(GlobalVariables.getPrematureParameters());
       
        Polygon2D pol2 =
                new ArrowMaster(GlobalVariables.getPrematureParameters()).segmentPfeilPol2D(
                        pol,
                        null,
                        ArrowMaster.EINFACHER_ABSCHLUSS,
                        ArrowMaster.EINFACHER_ABSCHLUSS,
                        new Vector2D(1, 1),
                        new Vector2D(1, 1));

        for (int i = 0; i < pol2.size(); i += 2) {
            pol2.remove(i);
        }
        for (int i = 0; i < pol2.size(); i += 2) {
            pol2.remove(i);
        }
        for (int i = 0; i < pol2.size(); i += 2) {
            pol2.remove(i);
        }
        for (int i = 0; i < pol2.size(); i += 2) {
            pol2.remove(i);
        }
        for (int i = 0; i < pol2.size(); i += 2) {
            pol2.remove(i);
        }
        for (int i = 0; i < pol2.size(); i += 2) {
            pol2.remove(i);
        }
        for (int i = 0; i < pol2.size(); i += 2) {
            pol2.remove(i);
        }

        return pol2;
    }
View Full Code Here

  @Override
  public Polygon2D getAgentShape() {
    if (circle == null) {
      final double precision = 20;
      final double radius = 0.3;
      circle = new Polygon2D();

      for (double d = 0; d < Math.PI * 2; d += Math.PI * 2 / precision) {
        circle.add(new Vector2D(Math.sin(d) * radius, Math.cos(d) * radius));
      }
    }
 
View Full Code Here

    @Override
    public synchronized Polygon2D getAgentShape() {
        // Auto-generated polygon code by Arrow Master (9 points)
        if (pol == null) {
            pol = new Polygon2D();

            pol.add(new Vector2D(240.0, 264.0));
            pol.add(new Vector2D(241.0, 309.0));
            pol.add(new Vector2D(278.0, 345.0));
            pol.add(new Vector2D(258.0, 399.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.