Enum ECardinalDirection2D

  • All Implemented Interfaces:
    Serializable, Comparable<ECardinalDirection2D>

    public enum ECardinalDirection2D
    extends Enum<ECardinalDirection2D>
    Enumeration with the cardinal directions in 2D space, corresponding the 4 main directions of a compass. The coordinate system is at the top left, with the x-axis pointing to the right and the y-axis pointing down.
    Since:
    8.4.0
    • Method Detail

      • values

        public static ECardinalDirection2D[] 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 (ECardinalDirection2D c : ECardinalDirection2D.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ECardinalDirection2D valueOf​(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:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • angleDegrees

        public int angleDegrees()
        The angle of this cardinal direction in degrees, where 0 is east, 90 is north, 180 is west, and 270 is south.
        Returns:
        The angle in degrees.
      • angleRadians

        public double angleRadians()
        The angle of this cardinal direction in radians, where 0 is east, π/2 is north, π is west, and 3π/2 is south.
        Returns:
        The angle in radians.
      • axis

        public ECartesianAxis2D axis()
        The cartesian axis of this cardinal direction.
        Returns:
        The cartesian axis.
      • polarity

        public EAxisPolarity polarity()
        The axis polarity of this cardinal direction.
        Returns:
        The axis polarity.
      • flip

        public ECardinalDirection2D flip()
        Rotates this direction by 180 degrees.
        Returns:
        The direction rotated 180 degrees.
      • negative

        public ECardinalDirection2D negative()
        Returns the cardinal direction obtained from this direction by settings the EAxisPolarity to NEGATIVE.
        Returns:
        This cardinal direction with the axis direction set to negative.
      • positive

        public ECardinalDirection2D positive()
        Returns the cardinal direction obtained from this direction by settings the EAxisPolarity to POSITIVE.
        Returns:
        This cardinal direction with the axis direction set to positive.
      • rotate45Left

        public EPrimaryIntercardinalDirection2D rotate45Left()
        Rotates this direction 45 degrees to the left.
        Returns:
        The direction rotated 45 degrees to the left.
      • rotate45Right

        public EPrimaryIntercardinalDirection2D rotate45Right()
        Rotates this direction 45 degrees to the right.
        Returns:
        The direction rotated 45 degrees to the right.
      • rotate90Left

        public ECardinalDirection2D rotate90Left()
        Rotates this direction 90 degrees to the left (counter-clockwise).
        Returns:
        The direction rotated 90 degrees to the left.
      • rotate90Right

        public ECardinalDirection2D rotate90Right()
        Rotates this direction 90 degrees to the right (clockwise).
        Returns:
        The direction rotated 90 degrees to the right.
      • unitVector

        public Point2DDouble unitVector()
        Gets the unit vector corresponding to this cardinal direction.
        Returns:
        The unit vector corresponding to this cardinal direction.
      • ofAxisAndPolarity

        public static ECardinalDirection2D ofAxisAndPolarity​(ECartesianAxis2D axis,
                                                             EAxisPolarity polarity)
        Returns the cardinal direction corresponding to the given axis and direction.
        Parameters:
        axis - The axis.
        polarity - The direction.
        Returns:
        The cardinal direction corresponding to the given axis and direction, or null if either is null.