| Enum Constant and Description |
|---|
EAST
East direction.
|
NORTH
North direction.
|
NORTHEAST
Northeast direction.
|
NORTHWEST
Northwest direction.
|
SOUTH
South direction.
|
SOUTHEAST
Southeast direction.
|
SOUTHWEST
Southwest direction.
|
WEST
West direction.
|
ZERO
Zero direction.
|
| Modifier and Type | Field and Description |
|---|---|
int |
dx
x-coordinate of this direction.
|
int |
dy
y-coordinate of this direction.
|
| Modifier and Type | Method and Description |
|---|---|
static Direction |
getDirection(int dx,
int dy)
Computes the direction that moves the closest from (0,0) to (dx,dy).
|
boolean |
isEqual(Direction dir)
Returns if this direction is equal to target direction.
|
float |
length()
Returns the euclidean norm of this direction.
|
Direction |
opposite()
Returns the opposite direction.
|
Direction |
rotateLeft()
Returns the direction obtained by rotating this direction 45 degrees to the left.
|
Direction |
rotateRight()
Returns the direction obtained by rotating this direction 45 degrees to the right.
|
static Direction |
valueOf(java.lang.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 NORTHWEST
public static final Direction WEST
public static final Direction SOUTHWEST
public static final Direction SOUTH
public static final Direction SOUTHEAST
public static final Direction EAST
public static final Direction NORTHEAST
public static final Direction ZERO
public final int dx
public final int dy
public static Direction[] values()
for (Direction c : Direction.values()) System.out.println(c);
public static Direction valueOf(java.lang.String name)
name - the name of the enum constant to be returned.java.lang.IllegalArgumentException - if this enum type has no constant with the specified namejava.lang.NullPointerException - if the argument is nullpublic boolean isEqual(Direction dir)
dir - Given direction.public Direction rotateLeft()
public Direction rotateRight()
public Direction opposite()
public float length()
public static Direction getDirection(int dx, int dy)
dx - x-coordinate of the targetdy - y-coordinate of the target