blob: daeb5816120e7e1fee3617199c32ecdbcc8d724d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
package ch.epfl.maze.physical.stragegies.planner;
import ch.epfl.maze.util.Direction;
import ch.epfl.maze.util.Vector2D;
/**
* @author Pacien TRAN-GIRARD
*/
public interface DistanceCalculator {
/**
* Returns the current position.
*
* @return The current position vector
*/
Vector2D getPosition();
/**
* Calculates the Euclidean distance from the adjacent position at the given Direction to the target position.
*
* @param dir The adjacent Direction
* @param targetPosition The targeted position
* @return The Euclidean distance between the two positions
*/
default double getDistanceTo(Direction dir, Vector2D targetPosition) {
return this
.getPosition()
.addDirectionTo(dir)
.sub(targetPosition)
.dist();
}
}
|