Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. @Override
  2. public float estimate(Node startNode, Node endNode) {
  3. int startIndex = startNode.getIndex();
  4. int endIndex = endNode.getIndex();
  5.  
  6. int startY = startIndex / MapManager.mapWidth;
  7. int startX = startIndex % MapManager.mapWidth;
  8.  
  9. int endY = endIndex / MapManager.mapWidth;
  10. int endX = endIndex % MapManager.mapWidth;
  11.  
  12. float distance = (float)Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2));
  13.  
  14. return distance;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement