Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<Location> getLocs(Location start, Location finish){
- List<Location> result = new ArrayList<Location>();
- result.add(start);
- Location currentPosition = start.clone();
- int iteration = 0;
- int deltaX = (int) (Math.max(Math.abs(start.getX()), Math.abs(finish.getX())) - Math.min(Math.abs(start.getX()), Math.abs(finish.getX())));
- int deltaZ = (int) (Math.max(Math.abs(start.getZ()), Math.abs(finish.getZ())) - Math.min(Math.abs(start.getZ()), Math.abs(finish.getZ())));
- if(finish.getX() < start.getX())
- deltaX *= -1;
- if(finish.getZ() < start.getZ())
- deltaZ *= -1;
- while(currentPosition != finish){//should copy entire cube in 2D square parts
- for(int i = 0; i < deltaZ; i++, currentPosition.add(0.0, 0.0, i)){
- for(int j = 0; j < deltaX; j++, currentPosition.add(j, 0.0, 0.0)){
- result.add(currentPosition.clone());
- }
- currentPosition = start.clone();
- }
- iteration++;
- currentPosition = start.clone().add(0.0, iteration, 0.0);
- }
- result.add(finish);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement