Package org.spongepowered.api.util
Enum Class Direction
- All Implemented Interfaces:
Serializable
,Comparable<Direction>
,Constable
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The compass division supported by this direction implementation.Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns the direction as a block offset vector.asOffset()
Returns the direction as a unit offset vector.static Direction
Gets the closest direction from the given vector.static Direction
closest
(Vector3d vector, Direction.Division smallestDivision) Gets the closest direction from the given vector.static Direction
closestHorizontal
(Vector3d vector) Gets the closest horizontal direction from the given vector.static Direction
closestHorizontal
(Vector3d vector, Direction.Division smallestDivision) Gets the closest horizontal direction from the given vector.static Direction
Gets the direction associated with the given axis.static Direction
fromAxis
(Axis axis, AxisDirection direction) Gets the direction of the axis along the givenAxisDirection
.boolean
Return true if the direction is of a cardinal direction (north, west east, and south).boolean
Returns whether the given direction is opposite this.boolean
Return true if the direction is of an ordinal direction (northwest, southwest, southeast, northeast).boolean
Return true if the direction is of a secondary ordinal direction (north-northwest, north-northeast, south-southwest, etc.).boolean
Return whether Y component is non-zero.opposite()
Gets the opposite direction i.e.static Direction
Returns the enum constant of this class with the specified name.static Direction[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NORTH
-
NORTH_NORTHEAST
-
NORTHEAST
-
EAST_NORTHEAST
-
EAST
-
EAST_SOUTHEAST
-
SOUTHEAST
-
SOUTH_SOUTHEAST
-
SOUTH
-
SOUTH_SOUTHWEST
-
SOUTHWEST
-
WEST_SOUTHWEST
-
WEST
-
WEST_NORTHWEST
-
NORTHWEST
-
NORTH_NORTHWEST
-
UP
-
DOWN
-
NONE
-
-
Method Details
-
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
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 nameNullPointerException
- if the argument is null
-
closest
Gets the closest direction from the given vector. If the vector is the 0-Vector, this method returnsNONE
. If the vector has the same horizontal and vertical length, a horizontal direction will be returned. If the vector is halfway between two directions the clockwise next will be selected.- Parameters:
vector
- The vector to convert to a direction- Returns:
- The closest horizontal direction.
-
closest
Gets the closest direction from the given vector. If the vector is the 0-Vector, this method returnsNONE
. If the vector has the same horizontal and vertical length, a horizontal direction will be returned. If the vector is halfway between two directions the clockwise next will be selected.- Parameters:
vector
- The vector to convert to a directionsmallestDivision
- The smallest compass division that can be returned- Returns:
- The closest horizontal direction.
-
closestHorizontal
Gets the closest horizontal direction from the given vector. If the vector is the 0-Vector (ignoring y), this method returnsNONE
. If the vector is halfway between two directions the clockwise next will be selected.- Parameters:
vector
- The vector to convert to a direction- Returns:
- The closest horizontal direction.
-
closestHorizontal
Gets the closest horizontal direction from the given vector. If the vector is the 0-Vector (ignoring y), this method returnsNONE
. If the vector is halfway between two directions the clockwise next will be selected.- Parameters:
vector
- The vector to convert to a directionsmallestDivision
- The smallest compass division that can be returned- Returns:
- The closest horizontal direction.
-
fromAxis
Gets the direction associated with the given axis.- Parameters:
axis
- The axis- Returns:
- The direction
-
fromAxis
Gets the direction of the axis along the givenAxisDirection
.- Parameters:
axis
- The axisdirection
- The direction along the axis- Returns:
- The direction
-
opposite
Gets the opposite direction i.e. 180 degrees from this direction.- Returns:
- The opposite direction
-
isOpposite
Returns whether the given direction is opposite this.- Parameters:
d
- Direction to test- Returns:
- True if it is opposite
-
isCardinal
public boolean isCardinal()Return true if the direction is of a cardinal direction (north, west east, and south).This evaluates as false for directions that have a non-zero Y-component.
- Returns:
- True if cardinal
-
isOrdinal
public boolean isOrdinal()Return true if the direction is of an ordinal direction (northwest, southwest, southeast, northeast).- Returns:
- True if ordinal
-
isSecondaryOrdinal
public boolean isSecondaryOrdinal()Return true if the direction is of a secondary ordinal direction (north-northwest, north-northeast, south-southwest, etc.).- Returns:
- True if secondary ordinal
-
isUpright
public boolean isUpright()Return whether Y component is non-zero.- Returns:
- True if the Y component is non-zero
-
asOffset
Returns the direction as a unit offset vector. This vector is also suitable as a unit direction vector.- Returns:
- The direction as an offset
-
asBlockOffset
Returns the direction as a block offset vector. For secondary ordinals the results are approximated to the nearest block.The difference between this offset and
asOffset()
is that a block offset has unit components instead of unit length.- Returns:
- The direction as a block offset
-