Package eas.math.geometry

Examples of eas.math.geometry.Rectangle2D


    public BufferedImage getOutsideView() {
        return this.neuroImage;
    }
   
    private boolean isVisible(Rectangle2D rect) {
        return rect.intersect(new Rectangle2D(new Vector2D(0, 0), new Vector2D(1600, 1280)))
                || new Rectangle2D(new Vector2D(0, 0), new Vector2D(1600, 1280)).isPointInside(rect.middle());
    }
View Full Code Here


   
    private Rectangle2D heightProfileBoundingBox = null;
   
    public double getHeightAtCoordinate(Vector2D coordinate) {
        if (this.heightProfileGridWidth == null) {
            Rectangle2D boundingBox = this.getBoundingBox(true);
            this.heightProfileGridWidth = boundingBox.getWidth() / (heightProfile.getColumnCount() - 1);
            this.heightProfileGridHeight = boundingBox.getHeight() / (heightProfile.getRowCount() - 1);
            this.heightProfileBoundingBox = new Rectangle2D(boundingBox);
        }
       
        if (!this.heightProfileBoundingBox.isPointInside(coordinate)) {
            return Double.NEGATIVE_INFINITY;
        }
View Full Code Here

            g = envView.createGraphics();
        } else {
            g = g2;
        }

        Rectangle2D clip = this.getClippingRectangle();
       
        g.clipRect(
                (int) clip.upperLeftCorner().x,
                (int) clip.upperLeftCorner().y,
                (int) clip.lowerRightCorner().x,
                (int) clip.lowerRightCorner().y);

        /*
         * Add visualization of non-visualized grid objects (i.e., all that
         * are no agents.
         */
 
View Full Code Here

    /**
     * This method should be fast if no changes to bounding box have been made.
     */
    @SuppressWarnings("unchecked")
    private void refreshLocalBoundingBox() {
        Rectangle2D newBoundingBox = super.getBoundingBox(false);
       
        if (newBoundingBox == null) {
            newBoundingBox = new Rectangle2D(new Vector2D(0, 0), new Vector2D(1, 1));
            this.localBoundingBox = newBoundingBox;
        }
       
        if (this.tileNumHorizontally <= 0) {
//            StaticMethods.logDebug("Number of tiles horizontally must be positive, is: " + this.tileNumHorizontally, this.getParCollection());
            return;
        }
        if (this.tileNumVertically <= 0) {
//            StaticMethods.logDebug("Number of tiles vertically must be positive, is: " + this.tileNumVertically, this.getParCollection());
            return;
        }
       
        // If bounding box changed (==> refresh and reset tile coordinates).
        if (this.oldBoundingBox == null
                || Math.abs(this.oldBoundingBox.upperLeftCorner().x - newBoundingBox.upperLeftCorner().x) > epsilon
                || Math.abs(this.oldBoundingBox.upperLeftCorner().y - newBoundingBox.upperLeftCorner().y) > epsilon
                || Math.abs(this.oldBoundingBox.lowerRightCorner().x - newBoundingBox.lowerRightCorner().x) > epsilon
                || Math.abs(this.oldBoundingBox.lowerRightCorner().y - newBoundingBox.lowerRightCorner().y) > epsilon) {
            double x1 = newBoundingBox.upperLeftCorner().x - boundingBuffer.x,
                   x2 = newBoundingBox.lowerRightCorner().x + boundingBuffer.x,
                   y1 = newBoundingBox.upperLeftCorner().y - boundingBuffer.y,
                   y2 = newBoundingBox.lowerRightCorner().y + boundingBuffer.y;
//            System.out.println("bound");
            tiles = new LinkedList[tileNumHorizontally][tileNumVertically];
            this.localBoundingBox = new Rectangle2D(new Vector2D(x1, y1), new Vector2D(x2, y2));
            this.oldBoundingBox = new Rectangle2D(newBoundingBox);
            this.tileCoordinates = new Rectangle2D[tileNumHorizontally][tileNumVertically];
            this.agentTouchingTiles.clear();
        }
    }
View Full Code Here

            Vector2D upperLeft = new Vector2D(left + tileWidth * tileID.x, up
                    + tileHeight * tileID.y);
            Vector2D lowerRight = new Vector2D(upperLeft.x + tileWidth,
                    upperLeft.y + tileHeight);

            this.tileCoordinates[(int) tileID.x][(int) tileID.y] = new Rectangle2D(
                    upperLeft, lowerRight);
        }
       
        return this.tileCoordinates[(int) tileID.x][(int) tileID.y];
    }
View Full Code Here

        double angle = this.getAgentAngle(agentID);
        Vector2D scale = this.getAgentScale(agentID);
        if (scale == null) {
            scale = new Vector2D(1, 1);
        }
        Rectangle2D boundingBox = this.getAgentShapeInEnvironment(agentID, pos, scale, angle).getBoundingBox();
       
        boolean result = super.removeAgent(agentID);
        if (result) {
            if (this.agentTouchingTiles.containsKey(agentID)) {
                this.removeAgentFromTileLists(agentID, boundingBox);
View Full Code Here

            ignoreIDs.add(agent.id());
        }
       
        double maxdist = 0;
        double distanz;
        Rectangle2D bound;
       
        /*
         * Find a point that is clearly beyond the last point occupied
         * by a part of an agent in ray direction. Determine by this a
         * maximal possible distance of a ray collision.
         */
        for (AgentType a : this.getAgents()) {
            bound = a.getAgentShape().getBoundingBox();
            distanz = position.distance(
                    this.getAgentPosition(a.id()))
                        + bound.getWidth()
                        + bound.getHeight();
            if (distanz > maxdist) {
                maxdist = distanz;
            }
        }

View Full Code Here

        }

        if (showTiles) {
        for (int i = 0; i < this.tileNumHorizontally; i++) {
                for (int j = 0; j < this.tileNumVertically; j++) {
                    Rectangle2D r = this.getTileRectangle(new Vector2D(i, j));
                    Polygon2D polInVis = super.getPolygonInVisualization(r.toPol2D());
                    Vector2D pos = polInVis.centerPoint();
                    g.setColor(Color.orange);
                    g.drawPolygon(polInVis.toPol());
//                    g.drawString(i + " / " + j, (float) pos.x, (float) pos.y);
                    g.drawString("" + this.getAgentsTouchingTile(new Vector2D(i, j)).size(), (float) pos.x, (float) pos.y);
View Full Code Here

        return pol;
    }
   
    @Override
    public void step(Wink simTime) {
        Rectangle2D bound = this.getEnvironment().getAgentShapeInEnvironment(this.id()).getBoundingBox();
        double agentRad = Math.sqrt(bound.getWidth() * bound.getWidth() + bound.getHeight() * bound.getHeight());
       
        double disturbanceFactor = 0.5;
        double gradientFactor = 0.3;
        Vector2D pos = this.getEnvironment().getAgentPosition(this.id());
        Vector2D vec = new Vector2D(this.getEnvironment().getGradientAtCoordinate(pos));
View Full Code Here

        BufferedImage buffImgFeld = this.copy(env.getOutsideView())// TODO - this is inefficient.
//        BufferedImage buffImgFeld = env.getOutsideView();
        Graphics2D g = buffImgFeld.createGraphics();

        try {
            Rectangle2D rect;
            rect = ((AbstractEnvironment2D) env).getClippingRectangle();
            g.setClip(
                    (int) rect.upperLeftCorner().x,
                    (int) rect.upperLeftCorner().y,
                    (int) (rect.upperLeftCorner().x + rect.getWidth()),
                    (int) (rect.upperLeftCorner().y + rect.getHeight()));
        } catch (Exception e1) {
        }
       
        AbstractAgent bester = this.bester(env.getAgents());
        int radius = 20;
View Full Code Here

TOP

Related Classes of eas.math.geometry.Rectangle2D

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.