|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmegamek.common.Coords
public class Coords
Coords stores x and y values. Since these are hexes, coordinates with odd x values are a half-hex down. Directions work clockwise around the hex, starting with zero at the top. -y 0 _____ 5 / \ 1 -x / \ +x \ / 4 \_____/ 2 3 +y
| Field Summary | |
|---|---|
double |
fitness
|
static double |
HEXSIDE
|
static int |
MAX_BOARD_HEIGHT
The maximum height of a board in number of hexes. |
static int |
MAX_BOARD_WIDTH
The maximum width of a board in number of hexes. |
int |
x
|
int |
y
|
| Constructor Summary | |
|---|---|
Coords()
Constructs a new coordinate pair at (0, 0). |
|
Coords(Coords c)
Constructs a new coordinate pair that is a duplicate of the parameter. |
|
Coords(int x,
int y)
Constructs a new coordinate pair at (x, y). |
|
| Method Summary | |
|---|---|
int |
degree(Coords d)
Returns the degree direction of another Coords. |
int |
direction(Coords d)
Returns the direction in which another coordinate lies; 0 if the coordinates are equal. |
int |
distance(Coords c)
Returns the distance to another coordinate. |
int |
distance(int distx,
int disty)
|
boolean |
equals(java.lang.Object object)
Coords are equal if their x and y components are equal |
java.lang.String |
getBoardNum()
Returns a string representing a coordinate in "board number" format. |
static Coords |
getFromHashCode(int hash)
Get the coordinates object for a given hash code. |
int |
hashCode()
Get the hash code for these coords. |
static java.util.ArrayList<Coords> |
intervening(Coords src,
Coords dest)
Returns an array of the Coords of hexes that are crossed by a straight line from the center of src to the center of dest, including src & dest. |
static java.util.ArrayList<Coords> |
intervening(Coords src,
Coords dest,
boolean split)
|
boolean |
isXOdd()
Tests whether the x coordinate of this coordinate is odd. |
static Coords |
nextHex(Coords current,
Coords destination)
Pass-thru version of the above that assumes current = iSrc. |
static Coords |
nextHex(Coords current,
IdealHex iSrc,
IdealHex iDest,
int[] directions)
Returns the first further hex found along the line from the centers of src to dest. |
double |
radian(Coords d)
Returns the radian direction of another Coords. |
java.lang.String |
toFriendlyString()
this makes the coordinates 1 based instead of 0 based to match the tiles diaplayed on the grid. |
java.lang.String |
toString()
|
Coords |
translated(int dir)
Returns a new coordinate that represents the coordinate 1 unit in the specified direction. |
Coords |
translated(int dir,
int distance)
|
Coords |
translated(java.lang.String dir)
|
static int |
xInDir(int x,
int y,
int dir)
Returns the x parameter of the coordinates in the direction |
static int |
xInDir(int x,
int y,
int dir,
int distance)
|
static int |
yInDir(int x,
int y,
int dir)
Returns the y parameter of the coordinates in the direction |
static int |
yInDir(int x,
int y,
int dir,
int distance)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final double HEXSIDE
public int x
public int y
public double fitness
public static final int MAX_BOARD_HEIGHT
public static final int MAX_BOARD_WIDTH
| Constructor Detail |
|---|
public Coords()
public Coords(int x,
int y)
public Coords(Coords c)
| Method Detail |
|---|
public final Coords translated(int dir)
dir - the direction.
public final Coords translated(int dir,
int distance)
public final Coords translated(java.lang.String dir)
public static final int xInDir(int x,
int y,
int dir)
public static final int xInDir(int x,
int y,
int dir,
int distance)
public static final int yInDir(int x,
int y,
int dir)
public static final int yInDir(int x,
int y,
int dir,
int distance)
public boolean isXOdd()
public int direction(Coords d)
d - the destination coordinate.public double radian(Coords d)
d - the destination coordinate.public int degree(Coords d)
d - the destination coordinate.public int distance(Coords c)
public int distance(int distx,
int disty)
public final java.lang.String getBoardNum()
public boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectint hash code for these coords.public static Coords getFromHashCode(int hash)
hash - - the hash code for the desired object.
Coords that match the hash code.public java.lang.String toString()
toString in class java.lang.Object
public static java.util.ArrayList<Coords> intervening(Coords src,
Coords dest)
public static java.util.ArrayList<Coords> intervening(Coords src,
Coords dest,
boolean split)
public static Coords nextHex(Coords current,
IdealHex iSrc,
IdealHex iDest,
int[] directions)
public static Coords nextHex(Coords current,
Coords destination)
public java.lang.String toFriendlyString()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||