Ejemplo n.º 1
0
	/**
	 * Defines the position of a location within the map. Using this method, one
	 * location should be selected as reference position (<code>dist=0</code>
	 * and <code>dir=0</code>) and all the other location should be placed
	 * relative to it.
	 * 
	 * @param loc
	 *            location name
	 * @param dist
	 *            distance to a reference position
	 * @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.Add(loc, coords);
	}
Ejemplo n.º 2
0
 /**
  * Returns the Euclidean distance between a specified point and this point.
  */
 public double distance(Point2D pt)
 {
     double result = (pt.getX() - x) * (pt.getX() - x);
     result += (pt.getY() - y) * (pt.getY() - y);
     return Math.Sqrt(result);
 }