Package org.spongepowered.api.util
Enum Axis
- java.lang.Object
-
- java.lang.Enum<Axis>
-
- org.spongepowered.api.util.Axis
-
- All Implemented Interfaces:
Serializable
,Comparable<Axis>
,Cycleable<Axis>
public enum Axis extends Enum<Axis> implements Cycleable<Axis>
Represents a three dimensional cartesian axis.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Axis
closest(Vector3d vector)
Gets the closest horizontal direction from the given vector.double
component(Vector3d vector3d)
Gets the component of the vector denoted by this axis.Axis
cycleNext()
Gets the "next"Cycleable
instance to be considered for cycling.AxisDirection
direction(Vector3d vector3d)
Gets the direction of the vector's component denoted by this axis.boolean
isVectorAlongAxis(Vector3d vector)
Returns whether the given vector is along this axis.Vector3d
toVector3d()
Gets the Vector3d backing this axis.Vector3d
toVector3dWithDirection(AxisDirection axisDirection)
Gets the Vector3d with the givenAxisDirection
.static Axis
valueOf(String name)
Returns the enum constant of this type with the specified name.static Axis[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static Axis[] 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 (Axis c : Axis.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Axis 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 nameNullPointerException
- 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 returnsX
. 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 directionX
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 givenAxisDirection
.- Parameters:
axisDirection
- The direction along the axis.- Returns:
- the Vector3d
-
-