Package de.xima.fc.common.geometry
Enum EPrimaryIntercardinalDirection2D
- java.lang.Object
-
- java.lang.Enum<EPrimaryIntercardinalDirection2D>
-
- de.xima.fc.common.geometry.EPrimaryIntercardinalDirection2D
-
- All Implemented Interfaces:
Serializable
,Comparable<EPrimaryIntercardinalDirection2D>
public enum EPrimaryIntercardinalDirection2D extends Enum<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 Constants Enum Constant Description 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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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.static EPrimaryIntercardinalDirection2D
between(ECardinalDirection2D first, ECardinalDirection2D second)
Calculates the primary intercardinal direction that is between the two specified cardinal directions.EPrimaryIntercardinalDirection2D
flip()
Rotates this direction by 180 degrees.static EPrimaryIntercardinalDirection2D
intercardinalDirection2DBetween(ECardinalDirection2D first, ECardinalDirection2D second)
Calculates the primary intercardinal direction that is between the two specified cardinal directions.static EPrimaryIntercardinalDirection2D
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_EAST
static EPrimaryIntercardinalDirection2D
ofAngleDegrees(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_EAST
static EPrimaryIntercardinalDirection2D
ofAngleRadians(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_EAST
ECardinalDirection2D
rotate45Left()
Rotates this direction 45 degrees to the left.ECardinalDirection2D
rotate45Right()
Rotates this direction 45 degrees to the right.EPrimaryIntercardinalDirection2D
rotate90Left()
Rotates this direction 90 degrees to the left.EPrimaryIntercardinalDirection2D
rotate90Right()
Rotates this direction 90 degrees to the right.static EPrimaryIntercardinalDirection2D
valueOf(String name)
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 Detail
-
NORTH_EAST
public static final EPrimaryIntercardinalDirection2D NORTH_EAST
The primary intercardinal direction between north and east.
-
NORTH_WEST
public static final EPrimaryIntercardinalDirection2D NORTH_WEST
The primary intercardinal direction between west and north.
-
SOUTH_EAST
public static final EPrimaryIntercardinalDirection2D SOUTH_EAST
The primary intercardinal direction between east and south.
-
SOUTH_WEST
public static final EPrimaryIntercardinalDirection2D SOUTH_WEST
The primary intercardinal direction between south and west.
-
-
Method Detail
-
values
public static EPrimaryIntercardinalDirection2D[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (EPrimaryIntercardinalDirection2D c : EPrimaryIntercardinalDirection2D.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static EPrimaryIntercardinalDirection2D valueOf(String name)
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
public EPrimaryIntercardinalDirection2D flip()
Rotates this direction by 180 degrees.- Returns:
- The direction rotated 180 degrees.
-
rotate45Left
public ECardinalDirection2D rotate45Left()
Rotates this direction 45 degrees to the left.- Returns:
- The direction rotated 45 degrees to the left.
-
rotate45Right
public ECardinalDirection2D rotate45Right()
Rotates this direction 45 degrees to the right.- Returns:
- The direction rotated 45 degrees to the right.
-
rotate90Left
public EPrimaryIntercardinalDirection2D rotate90Left()
Rotates this direction 90 degrees to the left.- Returns:
- The direction rotated 90 degrees to the left.
-
rotate90Right
public EPrimaryIntercardinalDirection2D 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, ifNORTH
andEAST
are given, returnsNORTH_EAST
.If the two cardinal directions are not adjacent (same or opposite), the return value is defined as follows: take the
angle
of 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, ifNORTH
andEAST
are given, returnsNORTH_EAST
.If the two cardinal directions are not adjacent (same or opposite), the return value is defined as follows: take the
angle
of 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
public static EPrimaryIntercardinalDirection2D ofAngleDegrees(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_EAST
- Parameters:
angleDegrees
- The angle in degrees.- Returns:
- The primary intercardinal direction corresponding to the specified angle.
- [0, 90) degrees:
-
ofAngleDegrees
public static EPrimaryIntercardinalDirection2D 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_EAST
- Parameters:
angleDegrees
- The angle in degrees.- Returns:
- The primary intercardinal direction corresponding to the specified angle.
- [0, 90) degrees:
-
ofAngleRadians
public static EPrimaryIntercardinalDirection2D ofAngleRadians(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_EAST
- Parameters:
angleRadians
- The angle in radians.- Returns:
- The primary intercardinal direction corresponding to the specified angle.
- [0, π/2) radians:
-
-