Enum EPrimaryIntercardinalDirection2D
java.lang.Object
java.lang.Enum<EPrimaryIntercardinalDirection2D>
de.xima.fc.common.geometry.EPrimaryIntercardinalDirection2D
- All Implemented Interfaces:
Serializable, Comparable<EPrimaryIntercardinalDirection2D>
Enumeration with the primary intercardinal directions in 2D space, corresponding to the four main intercardinal
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 ConstantsEnum ConstantDescriptionThe primary intercardinal direction between north and east.The primary intercardinal direction between west and north.The primary intercardinal direction between east and south.The primary intercardinal direction between south and west. -
Method Summary
Modifier and TypeMethodDescriptionintGets the angle of this direction in degrees, where 0 degrees is north, 90 degrees is east, 180 degrees is south, and 270 degrees is west.doubleGets the angle of this direction in radians, where 0 radians is north, π/2 radians is east, π radians is south, and 3π/2 radians is west.between(ECardinalDirection2D first, ECardinalDirection2D second) Calculates the primary intercardinal direction that is between the two specified cardinal directions.flip()Rotates this direction by 180 degrees.Calculates the primary intercardinal direction that is between the two specified cardinal directions.ofAngleDegrees(double angleDegrees) Calculates the primary intercardinal direction that is closest to the specified angle in degrees, defined as follows in terms of the angle when normalized to the range[0, 360): [0, 90) degrees:NORTH_EAST[90, 180) degrees:NORTH_WEST[180, 270) degrees:SOUTH_WEST[270, 360) degrees:SOUTH_EASTofAngleDegrees(long angleDegrees) Calculates the primary intercardinal direction that is closest to the specified angle in degrees, defined as follows in terms of the angle when normalized to the range[0, 360): [0, 90) degrees:NORTH_EAST[90, 180) degrees:NORTH_WEST[180, 270) degrees:SOUTH_WEST[270, 360) degrees:SOUTH_EASTofAngleRadians(double angleRadians) Calculates the primary intercardinal direction that is closest to the specified angle in radians, defined as follows in terms of the angle when normalized to the range[0, 2π): [0, π/2) radians:NORTH_EAST[π/2, π) radians:NORTH_WEST[π, 3π/2) radians:SOUTH_WEST[3π/2, 2π) radians:SOUTH_EASTRotates this direction 45 degrees to the left.Rotates this direction 45 degrees to the right.Rotates this direction 90 degrees to the left.Rotates this direction 90 degrees to the right.Returns the enum constant of this type with the specified name.static EPrimaryIntercardinalDirection2D[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
NORTH_EAST
The primary intercardinal direction between north and east. -
NORTH_WEST
The primary intercardinal direction between west and north. -
SOUTH_EAST
The primary intercardinal direction between east and south. -
SOUTH_WEST
The primary intercardinal direction between south and west.
-
-
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()Gets the angle of this direction in degrees, where 0 degrees is north, 90 degrees is east, 180 degrees is south, and 270 degrees is west.- Returns:
- The angle in degrees.
-
angleRadians
public double angleRadians()Gets the angle of this direction in radians, where 0 radians is north, π/2 radians is east, π radians is south, and 3π/2 radians is west.- Returns:
- The angle in radians.
-
flip
Rotates this direction by 180 degrees.- Returns:
- The direction rotated 180 degrees.
-
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.- Returns:
- The direction rotated 90 degrees to the left.
-
rotate90Right
Rotates this direction 90 degrees to the right.- Returns:
- The direction rotated 90 degrees to the right.
-
between
public static EPrimaryIntercardinalDirection2D between(ECardinalDirection2D first, ECardinalDirection2D second) Calculates the primary intercardinal direction that is between the two specified cardinal directions. For example, ifNORTHandEASTare given, returnsNORTH_EAST.If the two cardinal directions are not adjacent (same or opposite), the return value is defined as follows: take the
angleof both cardinal direction and take the smaller of the two angles. Start at that angle and move counter-clockwise, taking the first primary intercardinal direction that is encountered.- Parameters:
first- The first cardinal direction.second- The second cardinal direction.- Returns:
- The primary intercardinal direction between the two specified cardinal directions.
-
intercardinalDirection2DBetween
public static EPrimaryIntercardinalDirection2D intercardinalDirection2DBetween(ECardinalDirection2D first, ECardinalDirection2D second) Calculates the primary intercardinal direction that is between the two specified cardinal directions. For example, ifNORTHandEASTare given, returnsNORTH_EAST.If the two cardinal directions are not adjacent (same or opposite), the return value is defined as follows: take the
angleof both cardinal direction and take the smaller of the two angles. Start at that angle and move counter-clockwise, taking the first primary intercardinal direction that is encountered.- Parameters:
first- The first cardinal direction.second- The second cardinal direction.- Returns:
- The primary intercardinal direction between the two specified cardinal directions.
-
ofAngleDegrees
Calculates the primary intercardinal direction that is closest to the specified angle in degrees, defined as follows in terms of the angle when normalized to the range[0, 360):- [0, 90) degrees:
NORTH_EAST - [90, 180) degrees:
NORTH_WEST - [180, 270) degrees:
SOUTH_WEST - [270, 360) degrees:
SOUTH_EAST
- Parameters:
angleDegrees- The angle in degrees.- Returns:
- The primary intercardinal direction corresponding to the specified angle.
- [0, 90) degrees:
-
ofAngleDegrees
Calculates the primary intercardinal direction that is closest to the specified angle in degrees, defined as follows in terms of the angle when normalized to the range[0, 360):- [0, 90) degrees:
NORTH_EAST - [90, 180) degrees:
NORTH_WEST - [180, 270) degrees:
SOUTH_WEST - [270, 360) degrees:
SOUTH_EAST
- Parameters:
angleDegrees- The angle in degrees.- Returns:
- The primary intercardinal direction corresponding to the specified angle.
- [0, 90) degrees:
-
ofAngleRadians
Calculates the primary intercardinal direction that is closest to the specified angle in radians, defined as follows in terms of the angle when normalized to the range[0, 2π):- [0, π/2) radians:
NORTH_EAST - [π/2, π) radians:
NORTH_WEST - [π, 3π/2) radians:
SOUTH_WEST - [3π/2, 2π) radians:
SOUTH_EAST
- Parameters:
angleRadians- The angle in radians.- Returns:
- The primary intercardinal direction corresponding to the specified angle.
- [0, π/2) radians:
-