Exemplo n.º 1
0
 /**
  * Creates a new Direction from the three given nodes. When no previous node is given
  * the robot assumes it starts off facing the right direction.
  *
  * @param currentNode The poNodeint the robot is currently at.
  * @param nextNode The Node the robot is trying to get to next.
  * @param scale Coordinates/Unit of Measurement (ex: coordinates/meter) This is how the Direction
  * can take two Nodes' points with x and y coordinates and determine how many meters (or other unit of measurement)
  * that represents. You must be consistent with your scale throughout the project or you will be very unhappy.
  */
 public Direction(Node currentNode, Node nextNode, double scale)
 {
     this.previousPoint = null;
     this.currentPoint  = currentNode.CrossingPoint;
     this.nextPoint     = nextNode.CrossingPoint;
     _distance          = CoordinateCalculator.euclideanDistance(currentPoint, nextPoint) / scale;
 }
Exemplo n.º 2
0
 /**
  * Creates a new Direction from the two given points. When no previous point is given
  * the robot assumes it starts off facing the right direction.
  *
  * @param currentPoint The point the robot is currently at.
  * @param nextPoint The point the robot is trying to get to next.
  * @param scale Coordinates/Unit of Measurement (ex: coordinates/meter) This is how the Direction
  * can take two points with x and y coordinates and determine how many meters (or other unit of measurement)
  * that represents. You must be consistent with your scale throughout the project or you will be very unhappy.
  */
 public Direction(Point currentPoint, Point nextPoint, double scale)
 {
     this.previousPoint = null;
     this.currentPoint  = currentPoint;
     this.nextPoint     = nextPoint;
     _distance          = CoordinateCalculator.euclideanDistance(currentPoint, nextPoint) / scale;
 }
Exemplo n.º 3
0
        /*
         * Creates new edge between two nodes and adds it into the graph
         * @param n1 first node
         * @param n2 second node
         * @param scale
         * @param scale scale of the map in coordinates/units
         * (ex. if a line started at (0,0) and ended at (5,5) and had an actual length of 3 inches,
         * its scale would be 5/3 coordinates/inch)
         */
        public void addEdge(Node n1, Node n2, double scale)
        {
            double weight   = CoordinateCalculator.euclideanDistance(n1.CrossingPoint, n2.CrossingPoint) / scale;
            Edge   new_edge = new Edge(n1, n2, weight);

            addEdge(new_edge);
        }