Package rekit.primitives.geometry
Enum Class Direction
- All Implemented Interfaces:
Serializable
,Comparable<Direction>
,Constable
Representation of the 4 directions there are.
- Author:
- Angelo Aracri
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptiondouble
getAngle()
Get the angle to a corresponding direction relative to direction up.Get the next direction to a direction (anticlockwise).Get the next direction to a direction (clockwise).Get the opposite direction.static Direction
getOpposite
(Direction dir) Get the opposite direction to a direction.static Direction
Get a random Direction.Get the vector to a corresponding direction.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
-
UP
Represents the Direction up with the Vector (0|-1). -
RIGHT
Represents the Direction right with the Vector (1|0). -
DOWN
Represents the Direction down with the Vector (0|1). -
LEFT
Represents the Direction left with the Vector (-1|0).
-
-
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
-
getVector
Get the vector to a corresponding direction.- Returns:
- the vector
-
getAngle
public double getAngle()Get the angle to a corresponding direction relative to direction up.- Returns:
- the angle
-
getOpposite
Get the opposite direction to a direction.- Parameters:
dir
- the direction- Returns:
- the direction or random if dir == null
-
getNextClockwise
Get the next direction to a direction (clockwise).- Returns:
- the direction or
null
if none defined
-
getNextAntiClockwise
Get the next direction to a direction (anticlockwise).- Returns:
- the direction or
null
if none defined
-
getRandom
Get a random Direction.- Returns:
- the direction or
null
if none defined
-
getOpposite
Get the opposite direction.- Returns:
- the opposite direction
-