Enum ECardinalDirection2D
- All Implemented Interfaces:
Serializable, Comparable<ECardinalDirection2D>
Enumeration with the cardinal directions in 2D space, corresponding the 4 main directions of a compass. The
coordinate system is at the top left, with the x-axis pointing to the right and the y-axis pointing down.
- Since:
- 8.4.0
-
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionintThe angle of this cardinal direction in degrees, where 0 is east, 90 is north, 180 is west, and 270 is south.doubleThe angle of this cardinal direction in radians, where 0 is east, π/2 is north, π is west, and 3π/2 is south.axis()The cartesian axis of this cardinal direction.flip()Rotates this direction by 180 degrees.negative()Returns the cardinal direction obtained from this direction by settings theEAxisPolaritytoNEGATIVE.static ECardinalDirection2DofAxisAndPolarity(ECartesianAxis2D axis, EAxisPolarity polarity) Returns the cardinal direction corresponding to the given axis and direction.polarity()The axis polarity of this cardinal direction.positive()Returns the cardinal direction obtained from this direction by settings theEAxisPolaritytoPOSITIVE.Rotates this direction 45 degrees to the left.Rotates this direction 45 degrees to the right.Rotates this direction 90 degrees to the left (counter-clockwise).Rotates this direction 90 degrees to the right (clockwise).Gets the unit vector corresponding to this cardinal direction.static ECardinalDirection2DReturns the enum constant of this type with the specified name.static ECardinalDirection2D[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
NORTH
North, i.e. the negative y-direction. -
EAST
East, i.e. the positive x-direction. -
SOUTH
South, i.e. the positive y-direction. -
WEST
West, i.e. the negative x-direction.
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
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
-
angleDegrees
public int angleDegrees()The angle of this cardinal direction in degrees, where 0 is east, 90 is north, 180 is west, and 270 is south.- Returns:
- The angle in degrees.
-
angleRadians
public double angleRadians()The angle of this cardinal direction in radians, where 0 is east, π/2 is north, π is west, and 3π/2 is south.- Returns:
- The angle in radians.
-
axis
The cartesian axis of this cardinal direction.- Returns:
- The cartesian axis.
-
polarity
The axis polarity of this cardinal direction.- Returns:
- The axis polarity.
-
flip
Rotates this direction by 180 degrees.- Returns:
- The direction rotated 180 degrees.
-
negative
Returns the cardinal direction obtained from this direction by settings theEAxisPolaritytoNEGATIVE.- Returns:
- This cardinal direction with the axis direction set to negative.
-
positive
Returns the cardinal direction obtained from this direction by settings theEAxisPolaritytoPOSITIVE.- Returns:
- This cardinal direction with the axis direction set to positive.
-
rotate45Left
Rotates this direction 45 degrees to the left.- Returns:
- The direction rotated 45 degrees to the left.
-
rotate45Right
Rotates this direction 45 degrees to the right.- Returns:
- The direction rotated 45 degrees to the right.
-
rotate90Left
Rotates this direction 90 degrees to the left (counter-clockwise).- Returns:
- The direction rotated 90 degrees to the left.
-
rotate90Right
Rotates this direction 90 degrees to the right (clockwise).- Returns:
- The direction rotated 90 degrees to the right.
-
unitVector
Gets the unit vector corresponding to this cardinal direction.- Returns:
- The unit vector corresponding to this cardinal direction.
-
ofAxisAndPolarity
Returns the cardinal direction corresponding to the given axis and direction.- Parameters:
axis- The axis.polarity- The direction.- Returns:
- The cardinal direction corresponding to the given axis and direction, or null if either is null.
-