Advertisement
Guest User

Untitled

a guest
Jul 28th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. public static List<Location> getLocs(Location start, Location finish){
  2. List<Location> result = new ArrayList<Location>();
  3. result.add(start);
  4. Location currentPosition = start.clone();
  5. int iteration = 0;
  6. int deltaX = (int) (Math.max(Math.abs(start.getX()), Math.abs(finish.getX())) - Math.min(Math.abs(start.getX()), Math.abs(finish.getX())));
  7. int deltaZ = (int) (Math.max(Math.abs(start.getZ()), Math.abs(finish.getZ())) - Math.min(Math.abs(start.getZ()), Math.abs(finish.getZ())));
  8. if(finish.getX() < start.getX())
  9. deltaX *= -1;
  10. if(finish.getZ() < start.getZ())
  11. deltaZ *= -1;
  12. while(currentPosition != finish){//should copy entire cube in 2D square parts
  13. for(int i = 0; i < deltaZ; i++, currentPosition.add(0.0, 0.0, i)){
  14. for(int j = 0; j < deltaX; j++, currentPosition.add(j, 0.0, 0.0)){
  15. result.add(currentPosition.clone());
  16. }
  17. currentPosition = start.clone();
  18. }
  19. iteration++;
  20. currentPosition = start.clone().add(0.0, iteration, 0.0);
  21. }
  22. result.add(finish);
  23. return result;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement