org.globalse.arena.frag.util
Class MathVector

java.lang.Object
  |
  +--org.globalse.arena.frag.util.MathVector

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

class for a 3-D vector and some calc on it.

See Also:
Serialized Form

Field Summary
 double x
           
 double y
           
 double z
           
 
Constructor Summary
MathVector()
          Default Constructor.
MathVector(double _x, double _y, double _z)
          Constructor for setting the coordinates with the values of the parameters
 
Method Summary
 MathVector add(MathVector other)
          Adds the coordinates of the other MathVector to the coordinates of the current vector.
 java.lang.Object clone()
          Returns a copy of the instance of the object.
 boolean equals(java.lang.Object obj)
          Calculates wether the parameter object is equal with the current vector.
 double length()
          Returns the legth of the vector.
 MathVector normalize()
          Returns normalized MathVector.
 MathVector scale(double value)
          Multiplies each coordinate of the vector with the parameter value.
 MathVector sub(MathVector other)
          Substracts the coordinates of the oteher MathVector from the current vector.
 java.lang.String toString()
          Return the coordinates of the vector as a string.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public double x

y

public double y

z

public double z
Constructor Detail

MathVector

public MathVector()
Default Constructor. Initializes the variables.

MathVector

public MathVector(double _x,
                  double _y,
                  double _z)
Constructor for setting the coordinates with the values of the parameters
Parameters:
_x - the x coordinate
_y - the y coordinate
_z - the z coordinate
Method Detail

clone

public java.lang.Object clone()
Returns a copy of the instance of the object.
Returns:
copy of the instance
Overrides:
clone in class java.lang.Object

length

public double length()
Returns the legth of the vector.
Returns:
the length of the vector

add

public MathVector add(MathVector other)
Adds the coordinates of the other MathVector to the coordinates of the current vector.
Parameters:
other - the second vector
Returns:
the result of the two vectors

sub

public MathVector sub(MathVector other)
Substracts the coordinates of the oteher MathVector from the current vector.
Parameters:
other - the second vector
Returns:
a substraction of the two vectors.

scale

public MathVector scale(double value)
Multiplies each coordinate of the vector with the parameter value.
Parameters:
value - the value for the multiplication
Returns:
MathVector a new MathVector object after the calculation

normalize

public MathVector normalize()
Returns normalized MathVector. If the legnth of the current vector is negativ, a vector with zero coordinates is returned.
Returns:
the normalezed vector

equals

public boolean equals(java.lang.Object obj)
Calculates wether the parameter object is equal with the current vector.
Parameters:
obj - the second object
Returns:
a boolean value of the calculation; equals or not
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Return the coordinates of the vector as a string. return a string with the coordinates of the vector
Returns:
String string with the coordinates
Overrides:
toString in class java.lang.Object



This page is hosted by the Chair for Applied Software Engineering of the Technische Universität München.
Imprint (Impressum)