Gjør det mulig å sjekke om to retninger står rett på hverandre

This commit is contained in:
2020-03-23 12:45:50 +01:00
parent 693b9fb886
commit 7635c33d8a
2 changed files with 43 additions and 0 deletions

View File

@ -45,6 +45,17 @@ public enum Direction {
return null;
}
/**
* Checks whether two directions are perpendicular
* @param direction1 The first direction
* @param direction2 The second direction
* @return True if the directions are perpendicular
*/
public static boolean arePerpendicular(Direction direction1, Direction direction2) {
return direction1.equals(getLeftRotatedDirection(direction2)) ||
direction1.equals(getRightRotatedDirection(direction2));
}
/**
* Gets the reverse of a direction
* @param direction A direction