Package aima.core.util.datastructure

Examples of aima.core.util.datastructure.Point2D


  /**
   * Defines the position of a location as with respect to an orthogonal
   * coordinate system.
   */
  public void setPosition(String loc, double x, double y) {
    locationPositions.put(loc, new Point2D(x, y));
  }
View Full Code Here


   * @param dir
   *            bearing (compass direction) in which the location is seen from
   *            the reference position
   */
  public void setDistAndDirToRefLocation(String loc, double dist, int dir) {
    Point2D coords = new Point2D(-Math.sin(dir * Math.PI / 180.0) * dist,
        Math.cos(dir * Math.PI / 180.0) * dist);
    links.addVertex(loc);
    locationPositions.put(loc, coords);
  }
View Full Code Here

    double minX = Double.POSITIVE_INFINITY;
    double minY = Double.POSITIVE_INFINITY;
    double maxX = Double.NEGATIVE_INFINITY;
    double maxY = Double.NEGATIVE_INFINITY;
    for (String loc : locs) {
      Point2D xy = map.getPosition(loc);
      if (xy.getX() < minX)
        minX = xy.getX();
      if (xy.getY() < minY)
        minY = xy.getY();
      if (xy.getX() > maxX)
        maxX = xy.getX();
      if (xy.getY() > maxY)
        maxY = xy.getY();
    }
    this.setBorder(20, 20, 20, 100);
    adjustTransformation(minX, minY, maxX, maxY);
  }
View Full Code Here

   * Represents roads by lines and locations by name-labeled points.
   */
  protected void paintMap(java.awt.Graphics2D g2) {
    Map envMap = getMapEnv().getMap();
    for (String l1 : envMap.getLocations()) {
      Point2D pt1 = envMap.getPosition(l1);
      List<String> linkedLocs = envMap.getLocationsLinkedTo(l1);
      for (String l2 : linkedLocs) {
        Point2D pt2 = envMap.getPosition(l2);
        g2.setColor(Color.lightGray);
        g2.drawLine(x(pt1), y(pt1), x(pt2), y(pt2));
      }
    }
  }
View Full Code Here

  }

  /** The track of the agent is visualized with red lines. */
  private void paintTrack(java.awt.Graphics2D g2, Agent a) {
    Map map = getMapEnv().getMap();
    Point2D lastPt = null;
    g2.setColor(Color.red);
    for (String loc : getTrack(a)) {
      Point2D pt = map.getPosition(loc);
      if (pt != null && lastPt != null) {
        g2.drawLine(x(pt), y(pt), x(lastPt), y(lastPt));
      }
      lastPt = pt;
    }
View Full Code Here

    }
  }

  protected void paintLoc(java.awt.Graphics2D g2, String loc) {
    Map map = getMapEnv().getMap();
    Point2D pt = map.getPosition(loc);
    if (pt != null) {
      int x = x(pt);
      int y = y(pt);
      String info = "";
      List<String> track = new ArrayList<String>();
View Full Code Here

   */
  static class H2 extends AdaptableHeuristicFunction {

    public double h(Object state) {
      double result = 0.0;
      Point2D pt1 = map.getPosition((String) state);
      Point2D pt2 = map.getPosition((String) goal);
      if (pt1 != null && pt2 != null)
        result = pt1.distance(pt2);
      return result;
    }
View Full Code Here

  protected void paintMap(java.awt.Graphics2D g2) {
    Map envMap = getMapEnv().getMap();
    Map aMap = (agentMap != null) ? agentMap : envMap;
    List<Roadblock> roadblocks = new ArrayList<Roadblock>();
    for (String l1 : envMap.getLocations()) {
      Point2D pt1 = envMap.getPosition(l1);
      List<String> linkedLocs = envMap.getLocationsLinkedTo(l1);
      for (String l2 : aMap.getLocationsLinkedTo(l1))
        if (!linkedLocs.contains(l2))
          linkedLocs.add(l2);
      for (String l2 : linkedLocs) {
        Point2D pt2 = envMap.getPosition(l2);
        g2.setColor(Color.lightGray);
        g2.drawLine(x(pt1), y(pt1), x(pt2), y(pt2));
        boolean blockedInEnv = !envMap.getLocationsLinkedTo(l2)
            .contains(l1);
        boolean blockedInAgent = !aMap.getLocationsLinkedTo(l2)
View Full Code Here

  }
 
  /** Displays a map location. */
  protected void paintLoc(Graphics2D g2, String loc) {
    Map map = getMapEnv().getMap();
    Point2D pt = map.getPosition(loc);
    if (pt != null) {
      int x = x(pt);
      int y = y(pt);
      String info = "";
      List<String> track = new ArrayList<String>();
View Full Code Here

      return;
    }
    String[] locs = new String[marks.size()];
    for (int i = 0; i < marks.size(); i++) {
      MapNode node = marks.get(i);
      Point2D pt = new Point2D(node.getLon(), node.getLat());
      locs[i] = map.getNearestLocation(pt);
    }
    heuristic.adaptToGoal(locs[1], map);
    Agent agent = null;
    MapAgentFrame.SelectionState state = frame.getSelection();
View Full Code Here

TOP

Related Classes of aima.core.util.datastructure.Point2D

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.