summaryrefslogtreecommitdiff
path: root/src/ch/epfl/maze/physical/stragegies
diff options
context:
space:
mode:
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies')
-rw-r--r--src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java b/src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java
new file mode 100644
index 0000000..daeb581
--- /dev/null
+++ b/src/ch/epfl/maze/physical/stragegies/planner/DistanceCalculator.java
@@ -0,0 +1,33 @@
1package ch.epfl.maze.physical.stragegies.planner;
2
3import ch.epfl.maze.util.Direction;
4import ch.epfl.maze.util.Vector2D;
5
6/**
7 * @author Pacien TRAN-GIRARD
8 */
9public interface DistanceCalculator {
10
11 /**
12 * Returns the current position.
13 *
14 * @return The current position vector
15 */
16 Vector2D getPosition();
17
18 /**
19 * Calculates the Euclidean distance from the adjacent position at the given Direction to the target position.
20 *
21 * @param dir The adjacent Direction
22 * @param targetPosition The targeted position
23 * @return The Euclidean distance between the two positions
24 */
25 default double getDistanceTo(Direction dir, Vector2D targetPosition) {
26 return this
27 .getPosition()
28 .addDirectionTo(dir)
29 .sub(targetPosition)
30 .dist();
31 }
32
33}