public class GridPosition extends Object implements Cloneable, Serializable
| Modifier and Type | Field and Description |
|---|---|
protected int |
q
The Axial Q coordinate
|
protected int |
r
The Axial R coordinate
|
| Constructor and Description |
|---|
GridPosition(int q,
int r) |
| Modifier and Type | Method and Description |
|---|---|
GridPosition |
clone() |
boolean |
equals(Object obj)
Two positions are equal if they have the same q and r
|
String |
getCoordinates() |
static HexagonMap.Direction |
getDirectionFromNumber(int i) |
HexagonMap.Direction |
getDirectionTo(GridPosition otherPosition) |
int |
getDistance(GridPosition target) |
static int |
getDistance(GridPosition a,
GridPosition b)
Calculates the grid distance between two positions
|
GridPosition |
getNeighborPosition(HexagonMap.Direction direction)
Finds the adjacent position in the specified direction from this position
|
List<GridPosition> |
getPositionsInCircleArea(int radius) |
List<GridPosition> |
getPositionsOnCircleEdge(int radius)
Finds all positions that are on the edge of a circle in which this position is the centre.
|
int |
getQ() |
int |
getR() |
int |
hashCode() |
static GridPosition |
hexRound(double q,
double r)
Finds the position that best matches given non-integer coordinates
|
boolean |
isAdjacent(GridPosition otherPosition) |
List<GridPosition> |
line(GridPosition destination)
Finds all GridPositions that are on a getLine between this and the given position (the array includes this and
the destination positions)
|
String |
toString() |
protected final int q
protected final int r
public GridPosition(int q,
int r)
q - the axial Q coordinater - the axial R coordinatepublic GridPosition clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic boolean equals(Object obj)
public String getCoordinates()
public HexagonMap.Direction getDirectionTo(GridPosition otherPosition)
otherPosition - reference grid positionpublic int getDistance(GridPosition target)
public GridPosition getNeighborPosition(HexagonMap.Direction direction)
direction - in which to searchpublic List<GridPosition> getPositionsInCircleArea(int radius)
public List<GridPosition> getPositionsOnCircleEdge(int radius)
radius - circle radiuspublic int getQ()
public int getR()
public boolean isAdjacent(GridPosition otherPosition)
otherPosition - other hex grid positionpublic List<GridPosition> line(GridPosition destination)
destination - destination grid positionpublic static HexagonMap.Direction getDirectionFromNumber(int i)
public static int getDistance(GridPosition a, GridPosition b)
a - the start positionb - the destination positionpublic static GridPosition hexRound(double q, double r)
q - coordinater - coordinateCopyright © 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH. All rights reserved.