public enum Direction extends Enum<Direction>
Modifier and Type | Class and Description |
---|---|
static class |
Direction.Division
The compass division supported by this direction implementation.
|
Enum Constant and Description |
---|
DOWN |
EAST |
EAST_NORTHEAST |
EAST_SOUTHEAST |
NONE |
NORTH |
NORTH_NORTHEAST |
NORTH_NORTHWEST |
NORTHEAST |
NORTHWEST |
SOUTH |
SOUTH_SOUTHEAST |
SOUTH_SOUTHWEST |
SOUTHEAST |
SOUTHWEST |
UP |
WEST |
WEST_NORTHWEST |
WEST_SOUTHWEST |
Modifier and Type | Method and Description |
---|---|
com.flowpowered.math.vector.Vector3i |
asBlockOffset()
Returns the direction as a block offset vector.
|
com.flowpowered.math.vector.Vector3d |
asOffset()
Returns the direction as a unit offset vector.
|
static Direction |
getClosest(com.flowpowered.math.vector.Vector3d vector)
Gets the closest direction from the given vector.
|
static Direction |
getClosest(com.flowpowered.math.vector.Vector3d vector,
Direction.Division smallestDivision)
Gets the closest direction from the given vector.
|
static Direction |
getClosestHorizontal(com.flowpowered.math.vector.Vector3d vector)
Gets the closest horizontal direction from the given vector.
|
static Direction |
getClosestHorizontal(com.flowpowered.math.vector.Vector3d vector,
Direction.Division smallestDivision)
Gets the closest horizontal direction from the given vector.
|
static Direction |
getFromAxis(Axis axis)
Gets the direction associated with the given axis.
|
static Direction |
getFromAxis(Axis axis,
AxisDirection direction)
Gets the direction of the axis along the given
AxisDirection . |
Direction |
getOpposite()
Gets the opposite direction i.e.
|
boolean |
isCardinal()
Return true if the direction is of a cardinal direction (north, west
east, and south).
|
boolean |
isOpposite(Direction d)
Returns whether the given direction is opposite this.
|
boolean |
isOrdinal()
Return true if the direction is of an ordinal direction (northwest,
southwest, southeast, northeast).
|
boolean |
isSecondaryOrdinal()
Return true if the direction is of a secondary ordinal direction
(north-northwest, north-northeast, south-southwest, etc.).
|
boolean |
isUpright()
Return whether Y component is non-zero.
|
static Direction |
valueOf(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.
|
public static final Direction NORTH
public static final Direction NORTH_NORTHEAST
public static final Direction NORTHEAST
public static final Direction EAST_NORTHEAST
public static final Direction EAST
public static final Direction EAST_SOUTHEAST
public static final Direction SOUTHEAST
public static final Direction SOUTH_SOUTHEAST
public static final Direction SOUTH
public static final Direction SOUTH_SOUTHWEST
public static final Direction SOUTHWEST
public static final Direction WEST_SOUTHWEST
public static final Direction WEST
public static final Direction WEST_NORTHWEST
public static final Direction NORTHWEST
public static final Direction NORTH_NORTHWEST
public static final Direction UP
public static final Direction DOWN
public static final Direction NONE
public static Direction[] values()
for (Direction c : Direction.values()) System.out.println(c);
public static Direction valueOf(String name)
name
- the name of the enum constant to be returned.IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is nullpublic static Direction getClosest(com.flowpowered.math.vector.Vector3d vector)
NONE
. 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.vector
- The vector to convert to a directionpublic static Direction getClosest(com.flowpowered.math.vector.Vector3d vector, Direction.Division smallestDivision)
NONE
. 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.vector
- The vector to convert to a directionsmallestDivision
- The smallest compass division that can be
returnedpublic static Direction getClosestHorizontal(com.flowpowered.math.vector.Vector3d vector)
NONE
.
If the vector is halfway between two directions the clockwise next will
be selected.vector
- The vector to convert to a directionpublic static Direction getClosestHorizontal(com.flowpowered.math.vector.Vector3d vector, Direction.Division smallestDivision)
NONE
.
If the vector is halfway between two directions the clockwise next will
be selected.vector
- The vector to convert to a directionsmallestDivision
- The smallest compass division that can be
returnedpublic static Direction getFromAxis(Axis axis)
axis
- The axispublic static Direction getFromAxis(Axis axis, AxisDirection direction)
AxisDirection
.axis
- The axisdirection
- The direction along the axispublic Direction getOpposite()
public boolean isOpposite(Direction d)
d
- Direction to testpublic boolean isCardinal()
This evaluates as false for directions that have a non-zero Y-component.
public boolean isOrdinal()
public boolean isSecondaryOrdinal()
public boolean isUpright()
public com.flowpowered.math.vector.Vector3d asOffset()
public com.flowpowered.math.vector.Vector3i asBlockOffset()
The difference between this offset and asOffset()
is that
a block offset has unit components instead of unit length.