Enum Class Radius
- All Implemented Interfaces:
Serializable, Comparable<Radius>, Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum Constants -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionfloatarea(float radiusLength) Given an Iterable of Coord (such as a List or Set), a distance to expand outward by (using this Radius), and the bounding height and width of the map, gets a "thickened" group of Coord as a Set where each Coord in points has been expanded out by an amount no greater than distance.inCircle(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height) Gets a List of all Coord points withinradiusLengthofcenterusing Euclidean measurement (making a circle).inCircle(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height, List<Coord> buf) Gets a List of all Coord points withinradiusLengthofcenterusing Euclidean measurement (making a circle).inDiamond(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height) Gets a List of all Coord points withinradiusLengthofcenterusing Manhattan measurement (making a diamond).inDiamond(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height, List<Coord> buf) Gets a List of all Coord points withinradiusLengthofcenterusing Manhattan measurement (making a diamond).booleaninRange(int startx, int starty, int endx, int endy, int minRange, int maxRange) inSquare(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height) Gets a List of all Coord points withinradiusLengthofcenterusing Chebyshev measurement (making a square).inSquare(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height, List<Coord> buf) Gets a List of all Coord points withinradiusLengthofcenterusing Chebyshev measurement (making a square).Gets the appropriateMeasurementto pass to a constructor if you already have a Radius.onUnitShape(float distance, com.github.tommyettinger.random.EnhancedRandom rng) pointsInside(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height) pointsInside(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height, List<Coord> buf) pointsInside(Coord center, int radiusLength, boolean surpassEdges, int width, int height) floatradius(float dx, float dy) floatradius(float startx, float starty, float endx, float endy) floatfloatintroughDistance(int xPos, int yPos) static RadiusReturns the enum constant of this class with the specified name.static Radius[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SQUARE
In an unobstructed area the FOV would be a square.
This is the shape that would represent movement radius in an 8-way movement scheme with no additional cost for diagonal movement. -
DIAMOND
In an unobstructed area the FOV would be a diamond.
This is the shape that would represent movement radius in a 4-way movement scheme. -
CIRCLE
In an unobstructed area the FOV would be a circle.
This is the shape that would represent movement radius in an 8-way movement scheme with all movement cost the same based on distance from the source
-
-
Field Details
-
ALL
-
-
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
-
radius
-
radius
-
radius
public float radius(float startx, float starty, float endx, float endy) -
radius
public float radius(float dx, float dy) -
onUnitShape
-
area
public float area(float radiusLength) -
perimeter
public CoordOrderedSet perimeter(Coord center, int radiusLength, boolean surpassEdges, int width, int height) -
extend
-
inRange
public boolean inRange(int startx, int starty, int endx, int endy, int minRange, int maxRange) -
roughDistance
public int roughDistance(int xPos, int yPos) -
pointsInside
-
pointsInside
-
pointsInside
-
inSquare
public static List<Coord> inSquare(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height) Gets a List of all Coord points withinradiusLengthofcenterusing Chebyshev measurement (making a square). Appends Coords tobufif it is non-null, and returns either buf or a freshly-allocated List of Coord. IfsurpassEdgesis false, which is the normal usage, this will not produce Coords with x or y less than 0 or greater thanwidthorheight; if surpassEdges is true, then it can produce any Coords in the actual radius.- Parameters:
centerX- the center Coord xcenterY- the center Coord xradiusLength- the inclusive distance from (centerX,centerY) for Coords to use in the ListsurpassEdges- usually should be false; if true, can produce Coords with negative x/y or past width/heightwidth- the width of the area this can place Coords (exclusive, not relative to center, usually map width)height- the height of the area this can place Coords (exclusive, not relative to center, usually map height)- Returns:
- a new List containing the points within radiusLength of the center
-
inDiamond
public static List<Coord> inDiamond(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height) Gets a List of all Coord points withinradiusLengthofcenterusing Manhattan measurement (making a diamond). Appends Coords tobufif it is non-null, and returns either buf or a freshly-allocated List of Coord. IfsurpassEdgesis false, which is the normal usage, this will not produce Coords with x or y less than 0 or greater thanwidthorheight; if surpassEdges is true, then it can produce any Coords in the actual radius.- Parameters:
centerX- the center Coord xcenterY- the center Coord xradiusLength- the inclusive distance from (centerX,centerY) for Coords to use in the ListsurpassEdges- usually should be false; if true, can produce Coords with negative x/y or past width/heightwidth- the width of the area this can place Coords (exclusive, not relative to center, usually map width)height- the height of the area this can place Coords (exclusive, not relative to center, usually map height)- Returns:
- a new List containing the points within radiusLength of the center
-
inCircle
public static List<Coord> inCircle(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height) Gets a List of all Coord points withinradiusLengthofcenterusing Euclidean measurement (making a circle). Appends Coords tobufif it is non-null, and returns either buf or a freshly-allocated List of Coord. IfsurpassEdgesis false, which is the normal usage, this will not produce Coords with x or y less than 0 or greater thanwidthorheight; if surpassEdges is true, then it can produce any Coords in the actual radius.- Parameters:
centerX- the center Coord xcenterY- the center Coord xradiusLength- the inclusive distance from (centerX,centerY) for Coords to use in the ListsurpassEdges- usually should be false; if true, can produce Coords with negative x/y or past width/heightwidth- the width of the area this can place Coords (exclusive, not relative to center, usually map width)height- the height of the area this can place Coords (exclusive, not relative to center, usually map height)- Returns:
- a new List containing the points within radiusLength of the center
-
inSquare
public static List<Coord> inSquare(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height, List<Coord> buf) Gets a List of all Coord points withinradiusLengthofcenterusing Chebyshev measurement (making a square). Appends Coords tobufif it is non-null, and returns either buf or a freshly-allocated List of Coord. IfsurpassEdgesis false, which is the normal usage, this will not produce Coords with x or y less than 0 or greater thanwidthorheight; if surpassEdges is true, then it can produce any Coords in the actual radius.- Parameters:
centerX- the center Coord xcenterY- the center Coord xradiusLength- the inclusive distance from (centerX,centerY) for Coords to use in the ListsurpassEdges- usually should be false; if true, can produce Coords with negative x/y or past width/heightwidth- the width of the area this can place Coords (exclusive, not relative to center, usually map width)height- the height of the area this can place Coords (exclusive, not relative to center, usually map height)buf- the List of Coord to append points to; may be null to create a new List- Returns:
- buf, after appending Coords to it, or a new List if buf was null
-
inDiamond
public static List<Coord> inDiamond(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height, List<Coord> buf) Gets a List of all Coord points withinradiusLengthofcenterusing Manhattan measurement (making a diamond). Appends Coords tobufif it is non-null, and returns either buf or a freshly-allocated List of Coord. IfsurpassEdgesis false, which is the normal usage, this will not produce Coords with x or y less than 0 or greater thanwidthorheight; if surpassEdges is true, then it can produce any Coords in the actual radius.- Parameters:
centerX- the center Coord xcenterY- the center Coord xradiusLength- the inclusive distance from (centerX,centerY) for Coords to use in the ListsurpassEdges- usually should be false; if true, can produce Coords with negative x/y or past width/heightwidth- the width of the area this can place Coords (exclusive, not relative to center, usually map width)height- the height of the area this can place Coords (exclusive, not relative to center, usually map height)buf- the List of Coord to append points to; may be null to create a new List- Returns:
- buf, after appending Coords to it, or a new List if buf was null
-
inCircle
public static List<Coord> inCircle(int centerX, int centerY, int radiusLength, boolean surpassEdges, int width, int height, List<Coord> buf) Gets a List of all Coord points withinradiusLengthofcenterusing Euclidean measurement (making a circle). Appends Coords tobufif it is non-null, and returns either buf or a freshly-allocated List of Coord. IfsurpassEdgesis false, which is the normal usage, this will not produce Coords with x or y less than 0 or greater thanwidthorheight; if surpassEdges is true, then it can produce any Coords in the actual radius.- Parameters:
centerX- the center Coord xcenterY- the center Coord xradiusLength- the inclusive distance from (centerX,centerY) for Coords to use in the ListsurpassEdges- usually should be false; if true, can produce Coords with negative x/y or past width/heightwidth- the width of the area this can place Coords (exclusive, not relative to center, usually map width)height- the height of the area this can place Coords (exclusive, not relative to center, usually map height)buf- the List of Coord to append points to; may be null to create a new List- Returns:
- buf, after appending Coords to it, or a new List if buf was null
-
expand
Given an Iterable of Coord (such as a List or Set), a distance to expand outward by (using this Radius), and the bounding height and width of the map, gets a "thickened" group of Coord as a Set where each Coord in points has been expanded out by an amount no greater than distance. As an example, you could call this on a line generated by Bresenham, OrthoLine, or an LOS object's getLastPath() method, and expand the line into a thick "brush stroke" where this Radius affects the shape of the ends. This will never produce a Coord with negative x or y, a Coord with x greater than or equal to width, or a Coord with y greater than or equal to height.- Parameters:
distance- the distance, as measured by this Radius, to expand each Coord on points up towidth- the bounding width of the map (exclusive)height- the bounding height of the map (exclusive)points- an Iterable (such as a List or Set) of Coord that this will make a "thickened" version of- Returns:
- a Set of Coord that covers a wider area than what points covers; each Coord will be unique (it's a Set)
-
matchingMeasurement
Gets the appropriateMeasurementto pass to a constructor if you already have a Radius. Matches SQUARE to CHEBYSHEV, DIAMOND to MANHATTAN, and CIRCLE to EUCLIDEAN.- Returns:
- a
Measurementthat matches this; SQUARE to CHEBYSHEV, DIAMOND to MANHATTAN, etc. - See Also:
-