Package eas.math.geometry

Examples of eas.math.geometry.LineSegment2D


    //construct sensor LOV
    Vector2D sensorLOV = env.getNormalizedLOV(body.id());
    sensorLOV.rotate(Vector2D.NULL_VECTOR, angleToAgent);
    sensorLOV.setLength(cSensorReach);
   
    LineSegment2D sensorLine = new LineSegment2D(
        new Vector2D(bodyPos),
        new Vector2D(bodyPos).translate(sensorLOV));

    //find closest agent
    Double minDistance = Double.POSITIVE_INFINITY;
View Full Code Here


      Vector2D sonarLOV = new Vector2D(-sensorLOV.x, sensorLOV.y);
      double sonarLength = Math.tan(cSensorWidth/2) * d;
      // construct direction vector pointing to sonar line end points perpendicular to sensorLOV and of appropriate length
      sonarLOV.setLength(sonarLength);
     
      LineSegment2D sonarLine = new LineSegment2D(
          new Vector2D(sonarPoint).translate(sonarLOV),
          new Vector2D(sonarPoint).sub(sonarLOV));
     
      for (Iterator<Integer> iterator = agentsToCheck.iterator(); iterator.hasNext();) {
        Integer agentID = iterator.next();
View Full Code Here

        int width = this.getGridWidth();
        int height = this.getGridHeight();
        float epsilon = (float) 0.5;
       
        Rectangle2D r = new Rectangle2D(new Vector2D(0 - epsilon, 0 - epsilon), new Vector2D(width - epsilon, height - epsilon));
        LineSegment2D l = new LineSegment2D(new Vector2D(0 - epsilon, heightGO + epsilon), new Vector2D(this.getWidth() - epsilon, heightGO + epsilon));
        g.setColor(Color.red);
        g.drawPolygon(this.getPolygonInVisualization(l.toPol2D()).toPol());
        g.setStroke(new BasicStroke(5));
        g.setColor(Color.orange);
        g.drawPolygon(this.getPolygonInVisualization(r.toPol2D()).toPol());
       
        g.setColor(Color.black);
        g.setStroke(new BasicStroke(8));
       
        float maxX = Float.NEGATIVE_INFINITY;
        float minX = Float.POSITIVE_INFINITY;
       
        for (PacmanAgent2D p : this.agents.get(this.getCurrentAgentID()).getAgents()) {
            Vector2D pos = this.getAgentPosition(p.id());
            try {
                if (pos.x > maxX) {
                    maxX = (float) pos.x;
                }
                if (pos.x < minX) {
                    minX = (float) pos.x;
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
       
        LineSegment2D l2 = new LineSegment2D(
                new Vector2D(minX - epsilon, this.getGridHeight() - epsilon),
                new Vector2D(maxX + epsilon, this.getGridHeight() - epsilon));
        g.drawPolygon(this.getPolygonInVisualization(l2.toPol2D()).toPol());
       
        // Show text.
        if (this.showText != null) {
            this.showCyclesText = 20 + this.showText.length() * 2;
            this.showNewText = this.showText;
View Full Code Here

            final Vector2D            endFaktor) {

        Vector2D aktVekX;
        Vector2D aktVekY;
        Vector2D aktVek;
        LineSegment2D p, q;
       
        if (punkte == null || punkte.nPoints() < 2) {
            throw new RuntimeException("Zu wenige Segmente für Pfeil.");
        }
       
        List<Double> dick = dicken;
       
        if (dick == null) {
            dick = new ArrayList<Double>(punkte.nPoints());
            for (int i = 0; i < punkte.nPoints(); i++) {
                dick.add((double) this.pfeilDicke);
            }
        }
       
        Polygon2D pktList1 = new Polygon2D();
        Polygon2D pktList2 = new Polygon2D();

        // Pfeilanfang.
        Vector2D normAnf = new Vector2D(punkte.get(0));
        Vector2D orthoAnf;
        normAnf.sub(punkte.get(1));
        normAnf.norm();
        orthoAnf = new Vector2D(normAnf);
        orthoAnf.ortho();
        Iterator<Vector2D> it1 = pfeilAnfang.iterator();
        Polygon2D zwisch = new Polygon2D();
       
        while (it1.hasNext()) {
            aktVek = it1.next();
            aktVekX = new Vector2D(orthoAnf);
            aktVekY = new Vector2D(normAnf);
            aktVekX.mult(aktVek.x * anfFaktor.x * dick.get(0));
            aktVekY.mult(aktVek.y * anfFaktor.y * dick.get(0));
            aktVek = new Vector2D(aktVekX);
            aktVek.translate(aktVekY);
            aktVek.translate(punkte.get(0));
            zwisch.add(aktVek);
        }
       
        for (int i = zwisch.nPoints() - 1; i >= 0; i--) {
            pktList2.add(zwisch.get(i));
        }

        Polygon2D zwischPunkte;
       
        Vector2D c1 = new Vector2D(punkte.get(1));
        Vector2D c2;
        c1.sub(punkte.get(0));
        c1.ortho();
        c1.norm();
        c1.mult(dick.get(0) / 2);
       
        Vector2D p01 = new Vector2D(punkte.get(0));
        Vector2D p02 = new Vector2D(p01);
        Vector2D p11;
        Vector2D p12;
       
        p01.translate(c1);
        p02.sub(c1);
       
        pktList1.add(p01);
        pktList2.add(p02);
       
        for (int i = 1; i < punkte.nPoints() - 1; i++) {
            zwischPunkte = eas.math.geometry.Geometry2D.schnPkte(
                    punkte.get(i - 1),
                    punkte.get(i),
                    punkte.get(i + 1),
                    dick.get(i));
           
            p = new LineSegment2D(
                    zwischPunkte.get(0),
                    zwischPunkte.get(1));
            q = new LineSegment2D(
                    pktList1.get(pktList1.nPoints() - 1),
                    pktList2.get(pktList2.nPoints() - 1));
           
            if (p.intersects(q) == null) {
                pktList1.add(zwischPunkte.get(0));
                pktList2.add(zwischPunkte.get(1));
            } else {
                StaticMethods.log(StaticMethods.LOG_WARNING,
                              "Segment konnte nicht überschneidungsfrei "
View Full Code Here

        furthestDir.setLength(maxdist);
        furthest.translate(furthestDir);
       
        HashMap<AbstractAgent2D<?>, LinkedList<Vector2D>> schnittpunkte
            = new HashMap<AbstractAgent2D<?>, LinkedList<Vector2D>>();
        LineSegment2D s = new LineSegment2D(position, furthest);
        Polygon2D p;
       
        // Find all intersections of ray with agents.
        for (AbstractAgent2D<?> a : this.agents2D.values()) {
View Full Code Here

        Vector2D furthest = new Vector2D(position);
        Vector2D furthestDir = new Vector2D(direction);
        furthestDir.setLength(maxdist);
        furthest.translate(furthestDir);
        LineSegment2D s = new LineSegment2D(position, furthest);
       
        Vector2D positionTile = this.getTileID(position);
       
        List<Integer> touchingAgents = new LinkedList<Integer>();
        touchingAgents.addAll(this.getAgentsTouchingTile(positionTile));
       
        touchingAgents.removeAll(ignoreIDs);
        CollisionData nearestTouching = this.nearestTouchingIfSameTile(touchingAgents, s, position, positionTile);
        Vector2D lastTile = null;
       
        // Pixellinie auf Tiles zeichnen.
        if (nearestTouching == null || nearestTouching.getAgent() == null) {
            double x1 = s.getAnfPkt().x;
            double y1 = s.getAnfPkt().y;
            double x2 = s.getEndPkt().x;
            double y2 = s.getEndPkt().y;
            int xx1, xx2, yy1, yy2, aktXi, aktYi;
            double aktX, aktY, schrittX, schrittY;

//            double tileLaengeX = this.localBoundingBox.getBreite() / this.tileNumHorizontally;
//            double tileLaengeY = this.localBoundingBox.getHoehe() / this.tileNumVertically;
View Full Code Here

TOP

Related Classes of eas.math.geometry.LineSegment2D

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.