Class GENERIC

java.lang.Object
  |
  +--GENERIC

public class GENERIC
extends java.lang.Object

Abstract class for generally used functions its static methods can be accessed project wide

Version:
0.01
Author:
Michael Schifferdecker, Samuel Broscheit

Field Summary
(package private) static boolean DEBUG
          class internal debug switch
 
Constructor Summary
GENERIC()
           
 
Method Summary
(package private) static java.awt.geom.Point2D.Double add2DPoints(java.awt.geom.Point2D.Double t1, java.awt.geom.Point2D.Double t2)
          vector addition
(package private) static void debug(java.lang.String id, java.lang.String msg)
           
static double getAngleBetweenVectors(java.awt.geom.Point2D.Double a, java.awt.geom.Point2D.Double b)
          get the angle between to vectors (vector a and vector b)
static double getAngleToTurnFromDirections(char mySide, double playerBodyDir, double destinationDir)
          calculates the turn angle from the player's body dir to the dir of the destination object
the result can be passed to the player.actor.turn() method or can be used to calculate angles to object's in relation to the player's body direction
static double getDirectionToPointFromPlayer(java.awt.geom.Point2D.Double playerPosition, double playerBodyDirection, java.awt.geom.Point2D.Double destPosition)
          get the direction to an object (2DPoint) in relation to the body dir of the player
static double getInterceptDirFromDynObjects(DynObject myDynObject, DynObject targetDynObject, double mySpeed)
          Method getInterceptDirFromDynObjects.
static java.awt.geom.Point2D.Double getInterceptPointFromDynObjects(DynObject myDynObject, DynObject targetDynObject, double mySpeed)
          Method getInterceptPointFromDynObjects.
static double getNormedDoubleValue(double valueToNorm, double maxNormValue)
          norm a value to interval [0;1]
(package private) static java.awt.geom.Point2D.Double getNormedVector(java.awt.geom.Point2D.Double t)
          get normed vector
static double getVectorLength(java.awt.geom.Point2D.Double a)
          get the length of a given vector
(package private) static java.awt.geom.Point2D.Double scalarVectorMul(java.awt.geom.Point2D.Double t, double scal)
          scaler vector multiplication
(package private) static java.awt.geom.Point2D.Double sub2DPoints(java.awt.geom.Point2D.Double t1, java.awt.geom.Point2D.Double t2)
          vector subtraction
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

DEBUG

static boolean DEBUG
class internal debug switch
Constructor Detail

GENERIC

public GENERIC()
Method Detail

getNormedDoubleValue

public static double getNormedDoubleValue(double valueToNorm,
                                          double maxNormValue)
norm a value to interval [0;1]
Parameters:
valueToNorm - the value that has to be normed
maxNormValue - greatest value (= 1 after normation)
Returns:
double

getVectorLength

public static double getVectorLength(java.awt.geom.Point2D.Double a)
get the length of a given vector
Parameters:
a - a vector as 2DPoint which length has to be calculated
Returns:
length of vector a

getAngleBetweenVectors

public static double getAngleBetweenVectors(java.awt.geom.Point2D.Double a,
                                            java.awt.geom.Point2D.Double b)
get the angle between to vectors (vector a and vector b)
Parameters:
a - vector a
b - vector b
Returns:
angle between vectors in degrees

getDirectionToPointFromPlayer

public static double getDirectionToPointFromPlayer(java.awt.geom.Point2D.Double playerPosition,
                                                   double playerBodyDirection,
                                                   java.awt.geom.Point2D.Double destPosition)
get the direction to an object (2DPoint) in relation to the body dir of the player
Parameters:
playerPosition - current position of the player as 2DPoint
playerBodyDirection - the current direction of a player
destPosition - coordinates of destination object as 2DPoint
Returns:
directionToPoint in degrees

getAngleToTurnFromDirections

public static double getAngleToTurnFromDirections(char mySide,
                                                  double playerBodyDir,
                                                  double destinationDir)
calculates the turn angle from the player's body dir to the dir of the destination object
the result can be passed to the player.actor.turn() method or can be used to calculate angles to object's in relation to the player's body direction
Parameters:
mySide - char value for own side identifiert ("l" / "r")
playerBodyDir - the current direction of a player
destinationDir - may be calculated with GENERIC.getDirectionToPointFromPlayer()
Returns:
resulting angle to turn to object

getInterceptPointFromDynObjects

public static java.awt.geom.Point2D.Double getInterceptPointFromDynObjects(DynObject myDynObject,
                                                                           DynObject targetDynObject,
                                                                           double mySpeed)
Method getInterceptPointFromDynObjects. Calculates Intercept Point from the dir-Vector 2 Dynamic Objects
Parameters:
myDynObject - my pos
targetDynObject - target pos (ball)
mySpeed - my current speed
Returns:
Point2D.Double the calculated interception point

getInterceptDirFromDynObjects

public static double getInterceptDirFromDynObjects(DynObject myDynObject,
                                                   DynObject targetDynObject,
                                                   double mySpeed)
Method getInterceptDirFromDynObjects. Calculates Intercept direction
Parameters:
myDynObject - my pos
targetDynObject - target pos
mySpeed - my current speed
Returns:
double interception direction relative to my body direction

add2DPoints

static java.awt.geom.Point2D.Double add2DPoints(java.awt.geom.Point2D.Double t1,
                                                java.awt.geom.Point2D.Double t2)
vector addition
Parameters:
t1 - vector 1
t2 - vector 2
Returns:
Point2D.Double result vector

sub2DPoints

static java.awt.geom.Point2D.Double sub2DPoints(java.awt.geom.Point2D.Double t1,
                                                java.awt.geom.Point2D.Double t2)
vector subtraction
Parameters:
t1 - vector 1
t2 - vector 1
Returns:
Point2D.Double result vector

getNormedVector

static java.awt.geom.Point2D.Double getNormedVector(java.awt.geom.Point2D.Double t)
get normed vector
Parameters:
t - t
Returns:
Point2D.Double result vector

scalarVectorMul

static java.awt.geom.Point2D.Double scalarVectorMul(java.awt.geom.Point2D.Double t,
                                                    double scal)
scaler vector multiplication
Parameters:
t - t
scal - scal
Returns:
Point2D.Double result

debug

static void debug(java.lang.String id,
                  java.lang.String msg)