Enum Class Axis

java.lang.Object
java.lang.Enum<Axis>
org.spongepowered.api.util.Axis
All Implemented Interfaces:
Serializable, Comparable<Axis>, Constable, StringRepresentable, Cycleable<Axis>

public enum Axis extends Enum<Axis> implements Cycleable<Axis>, StringRepresentable
Represents a three dimensional cartesian axis.
  • Enum Constant Details

    • X

      public static final Axis X
    • Y

      public static final Axis Y
    • Z

      public static final Axis Z
  • Method Details

    • values

      public static Axis[] 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 Axis 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
    • closest

      public static Axis closest(Vector3d vector)
      Gets the closest horizontal direction from the given vector. If the vector is the 0-Vector, this method returns X. If the vector has the same length in a horizontal and vertical direction, a horizontal axis will be returned. If the vector has the same length in x and in z direction X will be returned.
      Parameters:
      vector - The vector to convert to a axis
      Returns:
      The closest axis.
    • isVectorAlongAxis

      public boolean isVectorAlongAxis(Vector3d vector)
      Returns whether the given vector is along this axis.
      Parameters:
      vector - The vector to test
      Returns:
      True if it is along this axis
    • component

      public double component(Vector3d vector3d)
      Gets the component of the vector denoted by this axis.
      Parameters:
      vector3d - The vector
      Returns:
      The value of the component
    • direction

      public AxisDirection direction(Vector3d vector3d)
      Gets the direction of the vector's component denoted by this axis.
      Parameters:
      vector3d - The vector
      Returns:
      The direction of the component
    • toVector3d

      public Vector3d toVector3d()
      Gets the Vector3d backing this axis.
      Returns:
      the Vector3d
    • toVector3dWithDirection

      public Vector3d toVector3dWithDirection(AxisDirection axisDirection)
      Gets the Vector3d with the given AxisDirection.
      Parameters:
      axisDirection - The direction along the axis.
      Returns:
      the Vector3d
    • cycleNext

      public Axis cycleNext()
      Description copied from interface: Cycleable
      Gets the "next" Cycleable instance to be considered for cycling.
      Specified by:
      cycleNext in interface Cycleable<Axis>
      Returns:
      The next value
    • serializationString

      public String serializationString()
      Specified by:
      serializationString in interface StringRepresentable