|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.util.DirectionUtil
public class DirectionUtil
Direction related utility functions.
| Field Summary | |
|---|---|
protected static int[] |
ANGLE_MAP
Used to map an angle to a fine compass direction. |
protected static String[] |
DIR_STRINGS
Direction constant string names. |
protected static int[] |
FINE_CCW_ROTATE
Used to rotate a fine compass direction counter-clockwise. |
protected static int[] |
FINE_CW_ROTATE
Used to rotate a fine compass direction clockwise. |
protected static String[] |
SHORT_DIR_STRINGS
Abbreviated direction constant string names. |
| Fields inherited from interface com.threerings.util.DirectionCodes |
|---|
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST |
| Constructor Summary | |
|---|---|
DirectionUtil()
|
|
| Method Summary | |
|---|---|
static int |
fromShortString(String dirstr)
Returns the direction code that corresponds to the supplied short string or DirectionCodes.NONE
if the string does not correspond to a known direction code. |
static int |
fromString(String dirstr)
Returns the direction code that corresponds to the supplied string or DirectionCodes.NONE if the
string does not correspond to a known direction code. |
static int |
getClosest(int direction,
int[] possible)
Get the direction closest to the specified direction, out of the directions in the possible list (preferring a clockwise match). |
static int |
getClosest(int direction,
int[] possible,
boolean preferCW)
Get the direction closest to the specified direction, out of the directions in the possible list. |
static int |
getClosestCardinal(int direction)
Get the cardinal direction closest to the specified direction (preferring a clockwise match). |
static int |
getDirection(double theta)
Returns which of the eight compass directions is associated with the specified angle theta. |
static int |
getDirection(double ax,
double ay,
double bx,
double by)
Returns which of the eight compass directions that point b lies in from point
a as one of the DirectionCodes direction constants. |
static int |
getDirection(int ax,
int ay,
int bx,
int by)
Returns which of the eight compass directions that point b lies in from point
a as one of the DirectionCodes direction constants. |
static int |
getDirection(Point a,
Point b)
Returns which of the eight compass directions that point b lies in from point
a as one of the DirectionCodes direction constants. |
static String[] |
getDirectionNames()
Returns an array of names corresponding to each direction constant. |
static int |
getFineDirection(double theta)
Returns which of the sixteen compass directions is associated with the specified angle theta. |
static int |
getFineDirection(int ax,
int ay,
int bx,
int by)
Returns which of the sixteen compass directions that point b lies in from
point a as one of the DirectionCodes direction constants. |
static int |
getFineDirection(Point a,
Point b)
Returns which of the sixteen compass directions that point b lies in from
point a as one of the DirectionCodes direction constants. |
static int |
getOpposite(int direction)
Returns the opposite of the specified direction. |
static void |
moveDirection(Point p,
int direction,
int dx,
int dy)
Move the specified point in the specified screen direction, adjusting by the specified adjustments. |
static int |
rotateCCW(int direction,
int ticks)
Rotates the requested fine direction constant counter-clockwise by the requested number of ticks. |
static int |
rotateCW(int direction,
int ticks)
Rotates the requested fine direction constant clockwise by the requested number of ticks. |
static String |
toShortString(int direction)
Returns an abbreviated string representation of the supplied direction code. |
static String |
toString(int direction)
Returns a string representation of the supplied direction code. |
static String |
toString(int[] directions)
Returns a string representation of an array of direction codes. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String[] DIR_STRINGS
protected static final String[] SHORT_DIR_STRINGS
protected static final int[] FINE_CW_ROTATE
protected static final int[] FINE_CCW_ROTATE
protected static final int[] ANGLE_MAP
| Constructor Detail |
|---|
public DirectionUtil()
| Method Detail |
|---|
public static String[] getDirectionNames()
public static String toString(int direction)
public static String toShortString(int direction)
public static int fromString(String dirstr)
DirectionCodes.NONE if the
string does not correspond to a known direction code.
public static int fromShortString(String dirstr)
DirectionCodes.NONE
if the string does not correspond to a known direction code.
public static String toString(int[] directions)
public static int rotateCW(int direction,
int ticks)
public static int rotateCCW(int direction,
int ticks)
public static int getOpposite(int direction)
public static int getClosestCardinal(int direction)
public static int getClosest(int direction,
int[] possible)
public static int getClosest(int direction,
int[] possible,
boolean preferCW)
preferCW - whether to prefer a clockwise match or a counter-clockwise match.
public static int getDirection(Point a,
Point b)
b lies in from point
a as one of the DirectionCodes direction constants. Note:
that the coordinates supplied are assumed to be logical (screen) rather than cartesian
coordinates and NORTH is considered to point toward the top of the screen.
public static int getDirection(int ax,
int ay,
int bx,
int by)
b lies in from point
a as one of the DirectionCodes direction constants. Note:
that the coordinates supplied are assumed to be logical (screen) rather than cartesian
coordinates and NORTH is considered to point toward the top of the screen.
public static int getDirection(double ax,
double ay,
double bx,
double by)
b lies in from point
a as one of the DirectionCodes direction constants. Note:
that the coordinates supplied are assumed to be logical (screen) rather than cartesian
coordinates and NORTH is considered to point toward the top of the screen.
public static int getDirection(double theta)
NORTH is considered to point toward the top of the screen.
public static int getFineDirection(Point a,
Point b)
b lies in from
point a as one of the DirectionCodes direction constants.
Note: that the coordinates supplied are assumed to be logical (screen) rather than
cartesian coordinates and NORTH is considered to point toward the top of the
screen.
public static int getFineDirection(int ax,
int ay,
int bx,
int by)
b lies in from
point a as one of the DirectionCodes direction constants.
Note: that the coordinates supplied are assumed to be logical (screen) rather than
cartesian coordinates and NORTH is considered to point toward the top of the
screen.
public static int getFineDirection(double theta)
NORTH is considered to point toward the top of the
screen.
public static void moveDirection(Point p,
int direction,
int dx,
int dy)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||