rcssjava
Class Utils

java.lang.Object
  extended by rcssjava.Utils

public class Utils
extends java.lang.Object

Math and other utility functions that don't depend on the world state.


Method Summary
static double acosDeg(double x)
          Arccosine (in degrees)
static double asinDeg(double x)
          Arcsine (in degrees)
static double atan2Deg(double y, double x)
          Arctangent (in degrees) of ratio
static double atanDeg(double x)
          Arctangent (in degrees)
static double cosDeg(double angDeg)
          Cosine of angle in degrees
static int getBallID()
          Get ball's object ID
static double getBisectorTwoAngles(double ang1, double ang2)
          Bisector of smallest angle made between given angles
static int getLeftPlayerID(int unum)
          Get left player's ID from uniform number
static int getPlayerID(int side, int unum)
          Get player's ID from side and uniform number
static java.lang.String getPlayModeString(int pm)
          Get text label for a playmode
static int getRightPlayerID(int unum)
          Get right player's ID from uniform number
static int getSideFromID(int id)
          Get player's or other object's side
static int getUnumFromID(int id)
          Get player's uniform number
static boolean isBall(int id)
          Is this the ball?
static boolean isGoal(int id)
          Is this a goal?
static boolean isLeftGoal(int id)
          Is this the left goal?
static boolean isLeftPlayer(int id)
          Is player on left team?
static boolean isPlayer(int id)
          Is this a player?
static boolean isRightGoal(int id)
          Is this the right goal?
static boolean isRightPlayer(int id)
          Is player on right team?
static double normalizeAngle(double angDeg)
          Normalize angle to be between -180 and 180
static int sign(double d)
          Integer sign of value
static double sinDeg(double angDeg)
          Sine of angle in degrees
static java.lang.String stripPath(java.lang.String filename)
          Remove absolute path from filename
static double tanDeg(double angDeg)
          Tangent of angle in degrees
static java.lang.String unescape(java.lang.String string)
          Replace characters escaped using backslashes with their escaped values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cosDeg

public static double cosDeg(double angDeg)
Cosine of angle in degrees

Parameters:
angDeg - angle in degrees
Returns:
cosine of angle

sinDeg

public static double sinDeg(double angDeg)
Sine of angle in degrees

Parameters:
angDeg - angle in degrees
Returns:
sine of angle

tanDeg

public static double tanDeg(double angDeg)
Tangent of angle in degrees

Parameters:
angDeg - angle in degrees
Returns:
tangent of angle

atanDeg

public static double atanDeg(double x)
Arctangent (in degrees)

Parameters:
x - tangent of angle
Returns:
angle in degrees

atan2Deg

public static double atan2Deg(double y,
                              double x)
Arctangent (in degrees) of ratio

Parameters:
y - numerator
x - denominator
Returns:
angle in degrees of y / x

acosDeg

public static double acosDeg(double x)
Arccosine (in degrees)

Parameters:
x - cosine of angle
Returns:
angle in degrees

asinDeg

public static double asinDeg(double x)
Arcsine (in degrees)

Parameters:
x - sine of angle
Returns:
angle in degrees

normalizeAngle

public static double normalizeAngle(double angDeg)
Normalize angle to be between -180 and 180

Parameters:
angDeg - angle in degrees
Returns:
normalized angle in degrees

sign

public static int sign(double d)
Integer sign of value

Parameters:
d - some value
Returns:
1 if d > 0 and -1 otherwise

getBisectorTwoAngles

public static double getBisectorTwoAngles(double ang1,
                                          double ang2)
Bisector of smallest angle made between given angles

Parameters:
ang1 - angle in degrees
ang2 - angle in degrees
Returns:
bisecting angle in degrees

isLeftPlayer

public static boolean isLeftPlayer(int id)
Is player on left team?

Parameters:
id - player ID
Returns:
true if player is on left team

isRightPlayer

public static boolean isRightPlayer(int id)
Is player on right team?

Parameters:
id - player ID
Returns:
true if player is on right team

isPlayer

public static boolean isPlayer(int id)
Is this a player?

Parameters:
id - object ID
Returns:
true if the object ID refers to a player

isLeftGoal

public static boolean isLeftGoal(int id)
Is this the left goal?

Parameters:
id - object ID
Returns:
true if the object ID corresponds to the left goal

isRightGoal

public static boolean isRightGoal(int id)
Is this the right goal?

Parameters:
id - object ID
Returns:
true if the object ID corresponds to the right goal

isGoal

public static boolean isGoal(int id)
Is this a goal?

Parameters:
id - object ID
Returns:
true if the object ID corresponds one of the goals

isBall

public static boolean isBall(int id)
Is this the ball?

Parameters:
id - object ID
Returns:
true if the object ID corresponds to the ball

getUnumFromID

public static int getUnumFromID(int id)
Get player's uniform number

Parameters:
id - player ID
Returns:
player's uniform number 1-11

getSideFromID

public static int getSideFromID(int id)
Get player's or other object's side

Parameters:
id - object ID
Returns:
side as int
See Also:
SoccerTypes.SIDE_ILLEGAL, SoccerTypes.SIDE_LEFT, SoccerTypes.SIDE_RIGHT

getBallID

public static int getBallID()
Get ball's object ID

Returns:
ball's object ID

getLeftPlayerID

public static int getLeftPlayerID(int unum)
Get left player's ID from uniform number

Parameters:
unum - uniform number 1-11
Returns:
player ID

getRightPlayerID

public static int getRightPlayerID(int unum)
Get right player's ID from uniform number

Parameters:
unum - uniform number 1-11
Returns:
player ID

getPlayerID

public static int getPlayerID(int side,
                              int unum)
Get player's ID from side and uniform number

Parameters:
side - side as int
unum - uniform number 1-11
Returns:
player ID
See Also:
SoccerTypes.SIDE_ILLEGAL, SoccerTypes.SIDE_LEFT, SoccerTypes.SIDE_RIGHT

getPlayModeString

public static java.lang.String getPlayModeString(int pm)
Get text label for a playmode

Parameters:
pm - playmode
Returns:
name of playmode

stripPath

public static java.lang.String stripPath(java.lang.String filename)
Remove absolute path from filename

Parameters:
filename - full path to file
Returns:
file name without path

unescape

public static java.lang.String unescape(java.lang.String string)
Replace characters escaped using backslashes with their escaped values

Parameters:
string - original string
Returns:
unescaped string