Enum Direction

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<Direction>

    public enum Direction
    extends java.lang.Enum<Direction>
    Represents the four main cardinal points.

    Angles are represented as an int value ranging from 0-2047, where the following is true:

    • 0 or 2048 is true South
    • 256 is true South-West
    • 512 is true West
    • 768 is true North-West
    • 1024 is true North
    • 1280 is true North-East
    • 1536 is true East
    • 1792 is true South-East
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      EAST
      Angles ranging from 1408 - 1663.
      NORTH
      Angles ranging from 896 - 1151.
      NORTH_EAST
      Angles ranging from 1152 - 1407.
      NORTH_WEST
      Angles ranging from 640 - 895.
      SOUTH
      Angles ranging from 0 - 127 and 1920 - 2047.
      SOUTH_EAST
      Angles ranging from 1664 - 1919.
      SOUTH_WEST
      Angles ranging from 128 - 383.
      WEST
      Angles ranging from 384 - 639.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Direction get​(int angle)
      Converts the angle value to the nearest cardinal direction.
      static int getAngleTo​(Locatable origin, Locatable locatable)  
      static int getAngleToDeg​(Locatable origin, Locatable locatable)  
      static Direction getDirectionTo​(Locatable origin, Locatable locatable)  
      static int toDegrees​(int angle)  
      static int toRS​(int degrees)  
      static Direction valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static Direction[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • SOUTH

        public static final Direction SOUTH
        Angles ranging from 0 - 127 and 1920 - 2047.
      • SOUTH_WEST

        public static final Direction SOUTH_WEST
        Angles ranging from 128 - 383.
      • WEST

        public static final Direction WEST
        Angles ranging from 384 - 639.
      • NORTH_WEST

        public static final Direction NORTH_WEST
        Angles ranging from 640 - 895.
      • NORTH

        public static final Direction NORTH
        Angles ranging from 896 - 1151.
      • NORTH_EAST

        public static final Direction NORTH_EAST
        Angles ranging from 1152 - 1407.
      • EAST

        public static final Direction EAST
        Angles ranging from 1408 - 1663.
      • SOUTH_EAST

        public static final Direction SOUTH_EAST
        Angles ranging from 1664 - 1919.
    • Method Detail

      • values

        public static Direction[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Direction c : Direction.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Direction valueOf​(java.lang.String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null
      • get

        public static Direction get​(int angle)
        Converts the angle value to the nearest cardinal direction.

        Each cardinal direction contains 256 angles, ranging between -128 and +128 of it's true value. Negative values and values above 2047 are wrapped accordingly

        Parameters:
        angle - the RS angle
        Returns:
        Nearest cardinal direction to the angle
      • getAngleToDeg

        public static int getAngleToDeg​(Locatable origin,
                                        Locatable locatable)
      • toRS

        public static int toRS​(int degrees)
      • toDegrees

        public static int toDegrees​(int angle)