Enum Class Direction

java.lang.Object
java.lang.Enum<Direction>
rekit.primitives.geometry.Direction
All Implemented Interfaces:
Serializable, Comparable<Direction>, Constable

public enum Direction extends Enum<Direction>
Representation of the 4 directions there are.
Author:
Angelo Aracri
  • Enum Constant Details

    • UP

      public static final Direction UP
      Represents the Direction up with the Vector (0|-1).
    • DOWN

      public static final Direction DOWN
      Represents the Direction down with the Vector (0|1).
    • LEFT

      public static final Direction LEFT
      Represents the Direction left with the Vector (-1|0).
  • Method Details

    • values

      public static Direction[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Direction valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getVector

      public Vec getVector()
      Get the vector to a corresponding direction.
      Returns:
      the vector
    • getAngle

      public double getAngle()
      Get the angle to a corresponding direction relative to direction up.
      Returns:
      the angle
    • getOpposite

      public static Direction getOpposite(Direction dir)
      Get the opposite direction to a direction.
      Parameters:
      dir - the direction
      Returns:
      the direction or random if dir == null
    • getNextClockwise

      public Direction getNextClockwise()
      Get the next direction to a direction (clockwise).
      Returns:
      the direction or null if none defined
    • getNextAntiClockwise

      public Direction getNextAntiClockwise()
      Get the next direction to a direction (anticlockwise).
      Returns:
      the direction or null if none defined
    • getRandom

      public static Direction getRandom()
      Get a random Direction.
      Returns:
      the direction or null if none defined
    • getOpposite

      public Direction getOpposite()
      Get the opposite direction.
      Returns:
      the opposite direction