Get the locations between the start and end location @param start The start location @param end The end location @param step The step size to use @return A list of all the locations between the locations
(Location start, Location end, double step)
| 17 | * @return A list of all the locations between the locations |
| 18 | */ |
| 19 | public static List<Location> getPath(Location start, Location end, double step) { |
| 20 | List<Location> locs = new ArrayList<>(); |
| 21 | locs.add(start); |
| 22 | Vector v = end.clone().subtract(start).toVector(); |
| 23 | v = v.normalize().multiply(step); |
| 24 | Location current = start.clone(); |
| 25 | while (current.distance(end) > step) { |
| 26 | locs.add(current.clone()); |
| 27 | current = current.add(v); |
| 28 | } |
| 29 | locs.add(end); |
| 30 | return locs; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Get the locations between the start and end location |