cz.cuni.pogamut.MessageObjects
Class Triple

java.lang.Object
  extended by cz.cuni.pogamut.MessageObjects.Triple
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class Triple
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable

Triple implemets triple of double - used in representation of location, rotation, velocity
Triple has couple handy methods like add, substract, distance (in 2D and in 3D) which are usefull while designing agent in complex virtual environment

See Also:
Serialized Form

Field Summary
static double EPSILON
           
private  int hashCode
           
 double x
           
 double y
           
 double z
           
 
Constructor Summary
Triple()
           
Triple(double[] triple)
           
Triple(double x, double y, double z)
           
Triple(Triple t)
           
 
Method Summary
static Triple add(Triple a, Triple b)
          makes addition, example call, we got triples x, y: z = x + y can be written like: z = add(x,y); or z = add(y,x);
static double angle(Triple a, Triple b)
          Returns angle in radians.
 Tuple2D asTuple2D()
          Returns tuple2d from x,y of this triple.
 Tuple3D asTuple3D()
           
 Vertex3D asVertex3D()
           
 java.lang.Object clone()
           
static double degToRad(double deg)
          Degrees to radians.
static double distanceInPlane(Triple a, Triple b)
          Computes Euclidean distance in 2D space, according to x and y aces
static double distanceInSpace(Triple a, Triple b)
          Computes Euclidean distance in 3D space
 java.lang.Double dot(Triple t)
          Dot product.
 boolean epsilonEquals(Triple a)
          Returns whether this == a (Triple.EPSILON precision)
 boolean epsilonEquals(Triple a, double epsilon)
          Returns whether this == a (epsilon precision)
 boolean equals(java.lang.Object obj)
           
private  int getHashCode()
           
 int hashCode()
           
 Triple inverse()
           
static Triple multiplyByNumber(Triple a, java.lang.Double b)
          multiple vector by a number - every coordination separately
static double multiScalar(Triple a, Triple b)
           
 Triple normalize()
          Normalize the vector.
static double radToDeg(double rad)
          Radians to degrees.
static double radToUTAngle(double angle)
           
static Triple rotateYawPitchRoll(Triple a, double yawRad, double pitchRad, double rollRad)
           
static Triple rotationAsVector(Triple rotationInRad)
           
static Triple rotationAsVectorUTUnits(Triple rotationInUTUnits)
           
 void setTriple(Triple newTriple)
           
static Triple subtract(Triple a, Triple b)
          makes subraction example call: z = x - y => z = subtract(x,y);
 java.lang.String toString()
           
static double utAngleToRad(double angle)
           
 double vectorSize()
           
static double vectorSize(Triple a)
          counts size of the vector - distance from the (0,0,0)
 boolean zero()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EPSILON

public static final double EPSILON
See Also:
Constant Field Values

x

public double x

y

public double y

z

public double z

hashCode

private final int hashCode
Constructor Detail

Triple

public Triple(double[] triple)

Triple

public Triple()

Triple

public Triple(double x,
              double y,
              double z)

Triple

public Triple(Triple t)
Method Detail

getHashCode

private int getHashCode()

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

dot

public java.lang.Double dot(Triple t)
Dot product.

Parameters:
t -
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setTriple

public void setTriple(Triple newTriple)

add

public static Triple add(Triple a,
                         Triple b)
makes addition, example call, we got triples x, y: z = x + y can be written like: z = add(x,y); or z = add(y,x);


normalize

public Triple normalize()
Normalize the vector.


subtract

public static Triple subtract(Triple a,
                              Triple b)
makes subraction example call: z = x - y => z = subtract(x,y);

Parameters:
a -
b -
Returns:
substraction of supplied vectors

multiplyByNumber

public static Triple multiplyByNumber(Triple a,
                                      java.lang.Double b)
multiple vector by a number - every coordination separately


distanceInSpace

public static double distanceInSpace(Triple a,
                                     Triple b)
Computes Euclidean distance in 3D space

Parameters:
a -
b -
Returns:
distance in space between supplied points

distanceInPlane

public static double distanceInPlane(Triple a,
                                     Triple b)
Computes Euclidean distance in 2D space, according to x and y aces

Parameters:
a -
b -
Returns:
distance in plane between supplied points

vectorSize

public static double vectorSize(Triple a)
counts size of the vector - distance from the (0,0,0)

Parameters:
a - - vector
Returns:
size

vectorSize

public double vectorSize()

zero

public boolean zero()

utAngleToRad

public static double utAngleToRad(double angle)

radToUTAngle

public static double radToUTAngle(double angle)

rotateYawPitchRoll

public static Triple rotateYawPitchRoll(Triple a,
                                        double yawRad,
                                        double pitchRad,
                                        double rollRad)

rotationAsVector

public static Triple rotationAsVector(Triple rotationInRad)
Parameters:
rotationInRad - in radians pitch, yaw, roll (same order as sent by GameBots)
Returns:

rotationAsVectorUTUnits

public static Triple rotationAsVectorUTUnits(Triple rotationInUTUnits)
Parameters:
rotationInRad - in UTUnits (0..65535) pitch, yaw, roll (same order as sent by GameBots)
Returns:

inverse

public Triple inverse()

multiScalar

public static double multiScalar(Triple a,
                                 Triple b)

epsilonEquals

public boolean epsilonEquals(Triple a,
                             double epsilon)
Returns whether this == a (epsilon precision)

Parameters:
a -
epsilon -
Returns:

epsilonEquals

public boolean epsilonEquals(Triple a)
Returns whether this == a (Triple.EPSILON precision)

Parameters:
a -
epsilon -
Returns:

angle

public static double angle(Triple a,
                           Triple b)
Returns angle in radians.

Parameters:
a -
b -
Returns:

degToRad

public static double degToRad(double deg)
Degrees to radians.

Parameters:
deg -
Returns:

radToDeg

public static double radToDeg(double rad)
Radians to degrees.

Parameters:
rad -
Returns:

asTuple3D

public Tuple3D asTuple3D()

asVertex3D

public Vertex3D asVertex3D()

asTuple2D

public Tuple2D asTuple2D()
Returns tuple2d from x,y of this triple.

Returns: